package com.hoo.service;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Hashtable;
import java.util.Vector;

import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;

public class Crm_Sap_Interface     {/*

	public JCO.Client mConnection;
	public JCO.Repository mRepository;

	*//** 新增客户 *//*
	private static final String SCM_XD01 = "ZIF_OMS_CUSTOMER_MAINTAIN";
	*//** 读库存 *//*
	private static final String SCM_MB52 = "ZIF_OMS_MAT_STOCK_GET";
	// "ZRFC_MM_READ_MB52";
	// "ZIF_OMS_MAT_STOCK_GET";
	*//** 读出入库单据 *//*
	private static final String SCM_MB51 = "ZIF_OMS_MAT_DOC_LIST_GET";
	*//** 新增销售订单 *//*
	private static final String SCM_VA01 = "ZIF_OMS_SALESORDER_CREATE";
	*//** 修改销售订单 *//*
	private static final String SCM_VA02 = "ZIF_OMS_SALESORDER_CHANGE";

	*//** 新增借项销售订单 *//*
	private static final String SCM_VA01JX = "ZIF_OMS_SALESDOCU_CREATEFROMDA";
	*//** 读1500整机数据 *//*
	private static final String SCM_MM03 = "ZIF_OMS_MATERIAL_LIST_GET";

	*//** 创建销售订单发货单 *//*
	private static final String SCM_VL01N = "ZIF_OMS_DELIVERY_CREATE";
	*//** 创建销售订单交货单 *//*
	private static final String SCM_VL02N = "ZIF_OMS_DELIVERY_POST";
	*//** 创建销售订单开票凭证 *//*
	private static final String SCM_VF01 = "ZIF_OMS_WRITE_VF01";

	*//** 创建到款到款 *//*
	private static final String SCM_F22 = "ZIF_OMS_ACC_DOCUMENT_POST";

	*//** 读1500整机与内外机配套关系 *//*
	private static final String SCM_CS03 = "ZIF_OMS_MAT_BOM_LIST_GET";

	*//** 冲销到款凭证 *//*
	private static final String F22_OFF = "ZIF_OMS_ACC_DOCUMENT_CANCEL";

	*//** 读SAP物料锁定成本 *//*
	private static final String OMS_GET = "ZIF_OMS_MAT_COST_LIST_GET";

	*//** 读SAP物料锁定成本 *//*
	private static final String SCM_AUX = "ZIF_OMS_BILLING_LIST";

	public void getConnection() throws SinocpcException {

		String sql4 = "select trim(note) from cpcdict where dictcode like '%Sap_Name%'";
		String sql3 = "select trim(note) from cpcdict where dictcode like '%Sap_Url%'";
		String sql2 = "select trim(note) from cpcdict where dictcode like '%Sap_Pwd%'";
		String sql1 = "select trim(note) from cpcdict where dictcode like '%Sap_Client%'";
		String sql5 = "select trim(note) from cpcdict where dictcode like '%Sap_YuYan%'";

		String sapclient = this.getDataCentre().strSelect(sql1); // 端口
		String sapuserid = this.getDataCentre().strSelect(sql4); // 用户名
		String sappwd = this.getDataCentre().strSelect(sql2); // 密码
		String sapurl = this.getDataCentre().strSelect(sql3); // IP
		String language = this.getDataCentre().strSelect(sql5); // 语言

		// String sapclient = "800";
		// String sapuserid = "oms";
		// String sappwd = "123456";
		// String sapurl = "100.100.80.141";
		// String language="ZH";

		// //String sapclient = "400";
		// String sapclient = "300";
		// String sapuserid = "oms";
		// String sappwd = "654321";
		// String sapurl = "100.100.80.121";

		try {
			mConnection = JCO.createClient(sapclient, // SAP client
					sapuserid, // userid
					sappwd, // password
					language, // language
					sapurl, // application server host name
					"00"); // system number
			mConnection.connect();
			mRepository = new JCO.Repository("ARAsoft", mConnection);
			System.out.println("SAP连接成功");

		} catch (Exception ex) {
			System.out.println("SAP连接不成功");
			throw new IllegalLogicException("JCO.Repository对象生成不成功");
		}

	}

	public static void main(String[] args) {
		Crm_Sap_Interface test = new Crm_Sap_Interface();

		try {

			test.getConnection();
			// test.putZRFC_SCM_WRITE_XD01("",0,1);
			// test.getItemInventory("10000000000043","10050");//10000000000099
			// test.getItemInventory1("ZRFC_MM_READ_MB52", "4F7392308902N", 12);
			// test.getZRFC_SCM_READ_MB51();
			// test.putZRFC_SD_WRITE_VA011();
			// test.putZIF_OMS_SALESDOCU_CREATEFROMDA();
			// test.getZRFC_SCM_READ_MM03_SAP("10000000000042");
			// test.ZIF_OMS_DELIVERY_CREATE_VL01N1();//80000100 80000101
			// 80000102
			// test.ZIF_OMS_DELIVERY_POST_VL02N();
			// test.ZIF_OMS_WRITE_VF011();
			// test.ZIF_OMS_ACC_DOCUMENT_POST_F_22();
			// test.ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CX();
			// test.putZIF_OMS_SALESORDER_CHANGE_VA02();
			// test.putZIF_OMS_SALESORDER_CHANGE_VA02();
			// test.ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CX();
			// test.getZRFC_SCM_READ_ZCOPCCB11("14517031000013");

		} catch (Exception ex) {
			System.out.println("SAP连接不成功");

		}
	}

	*//**
	 * 当 usable=2 时传SAP系统
	 * *//*
	public int db_connect(String oms_sap_no) throws SinocpcException {

		int usable = 0;
		String sql = "select nvl(usable,0) from aux_oms_sap k where oms_sap_no='"
				+ oms_sap_no + "'";
		usable = this.getDataCentre().intSelect(sql);
		return usable;
	}

	*//**
	 * 返回指定物料的库存数量：1570库存函数“ZRFC_MM_READ_MB52”
	 * *//*
	public String getItemInventory(String ip_matnr, String iv_vbeln,
			String zuzhi, String kuwei) throws SinocpcException {

		String sql = "";

		String qty = "0";

		JCO.Function function = null;
		JCO.Table ztmtrack = null;
		try {

			getConnection();
			function = createFunction(SCM_MB52); // 取物料数据表
			if (function == null) {
				System.out.println(SCM_MB52 + "在sap中没有发现");
			} else {
				*//**
				 *输入要读取物料号码
				 * *//*
				JCO.ParameterList input = function.getImportParameterList();
				input.setValue(ip_matnr, "IV_MATNR");// IP_MATNR IV_MATNR物料号码
				input.setValue(iv_vbeln, "IV_VBELN");// I销售单号

				JCO.ParameterList list = function.getTableParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
				*//**
				 * 输入指定的工厂地点
				 * 
				 * *//*
				JCO.Table it_werks = list.getTable("IT_WERKS");
				it_werks.appendRow();
				it_werks.setRow(0);
				it_werks.setValue("I", "SIGN");
				it_werks.setValue("EQ", "OPTION");
				it_werks.setValue(zuzhi, "LOW");
				it_werks.setValue("", "HIGH");

				*//**
				 * 输入指定的库存地点
				 * *//*
				JCO.Table it_lgort = list.getTable("IT_LGORT");
				it_lgort.appendRow();
				it_lgort.setRow(0);
				it_lgort.setValue("I", "SIGN");
				it_lgort.setValue("EQ", "OPTION");
				it_lgort.setValue(kuwei, "LOW");//
				it_lgort.setValue("", "HIGH");// 11103015000009

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}
				mConnection.execute(function);

				ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。
				System.out.println("ztmtrack.getNumRows() = "
						+ ztmtrack.getNumRows());
				if (ztmtrack.getNumRows() > 0) {
					ztmtrack.setRow(0);// 指定行
					String qty1 = ztmtrack.getString("LABST");
					sql = "select nvl(sum(" + qty1 + "),0) from dual ";
					qty = this.getDataCentre().strSelect(sql);

				}

			}
		} catch (Exception ex) {
			ex.printStackTrace();
			// throw new IllegalLogicException(ex.toString());

		} finally {
			if (mConnection != null) {
				mConnection.disconnect();
			}
		}

		return qty;
	}

	*//**
	 *差异金额凭证写SAP Add by chenli
	 **//*
	public void doDisfunds_Header(int notice_id, int sale_ent_type, String amt,
			String ip_bldat) throws SinocpcException {
		String sql = "";
		String comp_code = "";
		sql = "select bih.invoice_id from bill_invoice_header bih where bih.notice_id ="
				+ notice_id;
		int invoice_id = this.getDataCentre().intSelect(sql);
		if (invoice_id > 0) {
			sql = " select a.pi_no other_no,a.pi_no funds_no, "
					+ "  to_char(sysdate, 'yyyymmdd') DOC_DATE, '2' pzzs, "
					+ "  a.invoice_no,a.sale_ent_type, 		 "
					+ "  a.currency_code,case when a.sale_ent_type=1 then '1130' else '1500'end  comp_code, "
					+ "  to_char(sysdate,'yyyymmddhh24miss')fundsno, "
					+ "  'SA'doc_type,a.pi_no item_text,5 erp_sap_stat,2 erp_stat,2 rongzitype,b.order_cost_centre costcenter  "
					+ "  from bill_invoice_header a ,base_contract b   "
					+ "  where  a.org_id=b.org_id and a.invoice_id ="
					+ invoice_id;
			Hashtable hth = this.getDataCentre().oneRowSelect(sql);

			sql = "select count(1)\n"
					+ "  from bill_invoice_header a, bill_invoice_line b\n"
					+ " where a.stat = 5\n"
					+ "   and a.invoice_id = b.invoice_id\n"
					+ "   and b.fee_type = 29\n"
					+ "   and a.invoice_type = 2\n" + "   and a.is_red <> 2\n"
					+ "   and a.bill_type <> 2\n" + "   and a.invoice_id ="
					+ invoice_id;
			int sl = this.getDataCentre().intSelect(sql);

			if (sale_ent_type == 1) {
				if (sl > 0 && hth != null) {
					comp_code = (String) hth.get("comp_code");
					sql = "select a.*, rownum seq\n"
							+ "  from (select '溢装' ALLOC_NMBR,\n"
							+ "               1 linetype,\n"
							+ "               -"
							+ amt
							+ " amt,\n"
							+ "               '40' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               v.subjects_no sap_account,m.pi_no item_text \n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "        union\n"
							+ "        select '溢装' ALLOC_NMBR,\n"
							+ "               2 linetype,\n"
							+ "               "
							+ amt
							+ " amt,\n"
							+ "               '15' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               c.sap_code sap_account,m.pi_no item_text\n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
							+ "         order by a.linetype";
					Vector vcline = this.getDataCentre().multiRowSelect(sql);
					this.ZIF_OMS_ACC_DOCUMENT_POST_F_22_PK(hth, vcline,
							ip_bldat, invoice_id, 2, 2, 3, 0, 0, comp_code, 1,
							"溢装");

					sql = "select a.*, rownum seq\n"
							+ "  from (select '短装' ALLOC_NMBR,\n"
							+ "               1 linetype,\n"
							+ "               -"
							+ amt
							+ " amt,\n"
							+ "               '50' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               v.subjects_no sap_account,m.pi_no item_text \n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "        union\n"
							+ "        select '短装' ALLOC_NMBR,\n"
							+ "               2 linetype,\n"
							+ "               "
							+ amt
							+ " amt,\n"
							+ "               '05' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               c.sap_code sap_account,m.pi_no item_text\n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
							+ "         order by a.linetype";
					Vector vcline1 = this.getDataCentre().multiRowSelect(sql);
					this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline1, ip_bldat,
							invoice_id, 2, 2, 3, 0, 0, comp_code, 1, "短装");
				}
			}
			if (sale_ent_type == 3) {
				if (sl > 0 && hth != null) {
					sql = "select a.*, rownum seq\n"
							+ "  from (select '溢装' ALLOC_NMBR,\n"
							+ "               1 linetype,\n"
							+ "               -"
							+ amt
							+ " amt,\n"
							+ "               '40' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1500' COMP_CODE,\n"
							+ "               v.subjects_no sap_account,m.pi_no item_text \n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "        union\n"
							+ "        select '溢装' ALLOC_NMBR,\n"
							+ "               2 linetype,\n"
							+ "               "
							+ amt
							+ " amt,\n"
							+ "               '15' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1500' COMP_CODE,\n"
							+ "               c.sap_code sap_account,m.pi_no item_text\n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
							+ "         order by a.linetype";
					Vector vcline = this.getDataCentre().multiRowSelect(sql);
					this.ZIF_OMS_ACC_DOCUMENT_POST_F_22_PK(hth, vcline,
							ip_bldat, invoice_id, 2, 2, 3, 0, 0, comp_code, 1,
							"溢装");

					sql = "select a.*, rownum seq\n"
							+ "  from (select '短装' ALLOC_NMBR,\n"
							+ "               1 linetype,\n"
							+ "               -"
							+ amt
							+ " amt,\n"
							+ "               '50' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1500' COMP_CODE,\n"
							+ "               v.subjects_no sap_account,m.pi_no item_text \n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "        union\n"
							+ "        select '短装' ALLOC_NMBR,\n"
							+ "               2 linetype,\n"
							+ "               "
							+ amt
							+ " amt,\n"
							+ "               '05' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1500' COMP_CODE,\n"
							+ "               c.sap_code sap_account,m.pi_no item_text\n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
							+ "         order by a.linetype";
					Vector vcline1 = this.getDataCentre().multiRowSelect(sql);
					this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline1, ip_bldat,
							invoice_id, 2, 2, 3, 0, 0, comp_code, 1, "短装");
				}
			}
		}
	}

	*//**
	 * 读SAP出入库明细数据
	 * *//*
	public void doin_out(String yyyymmdd, String eeend) throws SinocpcException {

		if (yyyymmdd.length() == 0) {
			String sql = " select  to_char(sysdate,'yyyymmdd')-1 yyyymmdd  from   dual ";
			yyyymmdd = this.getDataCentre().strSelect(sql);
			eeend = yyyymmdd;
		}

		// this.getZRFC_SCM_READ_MB51("101","1520",yyyymmdd,eeend);
		// this.getZRFC_SCM_READ_MB51("501","1520",yyyymmdd);
		// this.getZRFC_SCM_READ_MB51("312","1520",yyyymmdd,eeend);
		// this.getZRFC_SCM_READ_MB51("102","1520",yyyymmdd);
		// this.getZRFC_SCM_READ_MB51("161","1520",yyyymmdd);
		// this.getZRFC_SCM_READ_MB51("311","1520",yyyymmdd,eeend);
		// this.getZRFC_SCM_READ_MB51("502","1520",yyyymmdd);
		this.getZRFC_SCM_READ_MB51("311", "1391", yyyymmdd, eeend, "1100");
		this.getZRFC_SCM_READ_MB51("601", "1391", yyyymmdd, eeend, "1100");
		this.getZRFC_SCM_READ_MB51("602", "1391", yyyymmdd, eeend, "1100");
		this.getZRFC_SCM_READ_MB51("312", "1391", yyyymmdd, eeend, "1100");
		this.getZRFC_SCM_READ_MB51("Z07", "1391", yyyymmdd, eeend, "1100");
		this.getZRFC_SCM_READ_MB51("Y72", "1391", yyyymmdd, eeend, "1100");
		this.getZRFC_SCM_READ_MB51("Y71", "1391", yyyymmdd, eeend, "1100");

		this.getZRFC_SCM_READ_MB51("311", "1300", yyyymmdd, eeend, "1130");
		this.getZRFC_SCM_READ_MB51("601", "1300", yyyymmdd, eeend, "1130");
		this.getZRFC_SCM_READ_MB51("602", "1300", yyyymmdd, eeend, "1130");
		this.getZRFC_SCM_READ_MB51("312", "1300", yyyymmdd, eeend, "1130");
		this.getZRFC_SCM_READ_MB51("Z07", "1300", yyyymmdd, eeend, "1130");
		this.getZRFC_SCM_READ_MB51("Y72", "1300", yyyymmdd, eeend, "1130");
		this.getZRFC_SCM_READ_MB51("Y71", "1300", yyyymmdd, eeend, "1130");

		String sql = " create table sale_inqty as "
				+ " select y.matnr erp_code,sum(y.menge)qty from sale_sap_inout_line y where y.bwart='101' "
				+ " group by y.matnr ";
		this.getDataCentre().execute(sql);

		sql = " update sale_prod_line f set f.already_in_qty=( select qty from sale_inqty y where f.erp_code=y.erp_code )"
				+ " where f.erp_code in(select erp_code from sale_inqty ) ";
		this.getDataCentre().update(sql);

		sql = " drop table sale_inqty ";
		this.getDataCentre().execute(sql);

	}

	*//**
	 * 读1520 1570 出入库凭证 140520120208
	 * 
	 * @throws SinocpcException
	 * *//*
	public void getZRFC_SCM_READ_MB51(String orgsaptype, String orgsap,
			String yyyymmdd, String eeend, String werk) throws SinocpcException {
		// "101","1520",yyyymmdd

		if (this.db_connect(SCM_MB51) == 2) {
			String sql = "";
			JCO.Function function = null;
			JCO.Table ztmtrack = null;

			getConnection();
			function = createFunction(SCM_MB51); // 取物料数据表
			if (function == null) {
				System.out.println(SCM_MB51 + "在sap中没有发现");
			} else {

				JCO.ParameterList list = function.getTableParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值

				ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。
				*//**
				 * 输入指定的工厂地点
				 * *//*
				JCO.Table it_werks = list.getTable("IT_WERKS");
				it_werks.appendRow();
				it_werks.setRow(0);
				it_werks.setValue("I", "SIGN");
				it_werks.setValue("EQ", "OPTION");
				it_werks.setValue(werk, "LOW");
				it_werks.setValue("", "HIGH");

				*//**
				 * 输入指定的库存地点
				 * *//*
				JCO.Table it_lgort = list.getTable("IT_LGORT");

				it_lgort.appendRow();
				it_lgort.setRow(0);
				it_lgort.setValue("I", "SIGN");
				it_lgort.setValue("EQ", "OPTION");
				it_lgort.setValue(orgsap, "LOW");
				it_lgort.setValue("", "HIGH");// 11103015000009

				*//**
				 * 移动类型输入表
				 * *//*
				JCO.Table it_bwart = list.getTable("IT_BWART");
				it_bwart.appendRow();
				it_bwart.setRow(0);
				it_bwart.setValue("I", "SIGN");
				it_bwart.setValue("EQ", "OPTION");
				it_bwart.setValue(orgsaptype, "LOW");
				it_bwart.setValue("", "HIGH");

				*//**
				 * 记帐日期输入表
				 * *//*
				JCO.Table it_budat = list.getTable("IT_BUDAT");
				it_budat.appendRow();
				it_budat.setRow(0);
				it_budat.setValue("I", "SIGN");
				it_budat.setValue("BT", "OPTION");
				it_budat.setValue(yyyymmdd, "LOW");
				it_budat.setValue(eeend, "HIGH");

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}
				mConnection.execute(function);

				// if(1==1)throw new
				// IllegalLogicException(ztmtrack.getNumRows());
				System.out.println("ztmtrack.getNumRows() = "
						+ ztmtrack.getNumRows());
				for (int i = 0; i < ztmtrack.getNumRows(); i++) {
					ztmtrack.setRow(i);// 指定行
					String menge = "";
					String matnr = "";
					matnr = ztmtrack.getString("MATNR").trim();
					if (matnr.length() > 0
							&& matnr.substring(0, 5).equals("4F739")) {

						// 判断出入库类型 S 代表入库 H 代表出库
						if (ztmtrack.getString("SHKZG").equals("S")) {
							menge = ztmtrack.getString("MENGE");
						} else {
							menge = "-" + ztmtrack.getString("MENGE");
						}
						sql = "insert into sale_sap_inout_line ( "
								+ " inout_id,mblnr,mjahr,zeile,budat,matnr,maktx,lgort,lgobe1,umlgo,lgobe2,"
								+ " bwart,menge,meins,werks,meins_c,create_time ) values ( "
								+ this.getDataCentre().IDGenerator(
										"sale_sap_inout_line", "inout_id")
								+ ",'"
								+ ztmtrack.getString("MBLNR")
								+ "','"
								+ ztmtrack.getString("MJAHR")
								+ "','"
								+ ztmtrack.getString("ZEILE")
								+ "','"
								+ ztmtrack.getString("BUDAT")
								+ "','"
								+ ztmtrack.getString("MATNR")
								+ "','"
								+ ztmtrack.getString("MAKTX")
								+ "','"
								+ ztmtrack.getString("LGORT")
								+ "','"
								+ ztmtrack.getString("LGOBE1")
								+ "','"
								+ ztmtrack.getString("UMLGO")
								+ "','"
								+ ztmtrack.getString("LGOBE2")
								+ "','"
								+ ztmtrack.getString("BWART")
								+ "','"
								+ menge
								+ "','"
								+ ztmtrack.getString("MEINS")
								+ "','"
								+ ztmtrack.getString("WERKS")
								+ "','"
								+ ztmtrack.getString("MEINS_C") + "',sysdate )";
						this.getDataCentre().execute(sql);

					}
				}
			}

			if (mConnection != null) {
				mConnection.disconnect();
			}
		}

	}

	*//**
	 *读取SAP 1520 1570 时时库存数量
	 * *//*
	public void getZRFC_SCM_READ_MB52(int low) throws SinocpcException {

		if (this.db_connect("ZRFC_MM_READ_MB52_V1") == 2) {
			String sql = "";
			JCO.Function function = null;
			JCO.Table ztmtrack = null;
			try {
				getConnection();
				function = createFunction("ZRFC_MM_READ_MB52_V1"); // 取物料数据表
				if (function == null) {
					System.out.println("ZRFC_MM_READ_MB52_V1" + "在sap中没有发现");
				} else {

					*//**
					 *输入要读取物料号码
					 * *//*
					JCO.ParameterList input = function.getImportParameterList();
					// input.setValue("11103018000001", "IP_MATNR");

					JCO.ParameterList list = function.getTableParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值

					ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。
					*//**
					 * 输入指定的工厂地点
					 * *//*
					JCO.Table it_werks = list.getTable("IT_WERKS");
					it_werks.appendRow();
					it_werks.setRow(0);
					it_werks.setValue("I", "SIGN");
					it_werks.setValue("EQ", "OPTION");
					it_werks.setValue("1500", "LOW");
					it_werks.setValue("", "HIGH");

					*//**
					 * 输入指定的库存地点
					 * *//*
					JCO.Table it_lgort = list.getTable("IT_LGORT");

					it_lgort.appendRow();
					it_lgort.setRow(0);
					it_lgort.setValue("I", "SIGN");
					it_lgort.setValue("EQ", "OPTION");
					it_lgort.setValue(low, "LOW");
					it_lgort.setValue("", "HIGH");// 11103015000009

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}
					mConnection.execute(function);

					System.out.println("ztmtrack.getNumRows() = "
							+ ztmtrack.getNumRows());
					for (int i = 0; i < ztmtrack.getNumRows(); i++) {
						ztmtrack.setRow(i);// 指定行

						String matnr = "";
						matnr = ztmtrack.getString("MATNR").trim();
						if (matnr.length() > 0
								&& matnr.substring(0, 5).equals("4F739")
								|| matnr.equals("T15180184600")) {

							sql = "select count(0) from sale_sap_inventory where "
									+ " erp_code='"
									+ matnr
									+ "'"
									+ " and lgort='"
									+ ztmtrack.getString("LGORT").trim() + "'";
							if (this.getDataCentre().intSelect(sql) == 0) {
								sql = " insert into sale_sap_inventory ( "
										+ " erp_code,erp_name,werks,lgort,lgobe,qty,uom_name,update_time "
										+ " )values( '" + matnr + "','"
										+ ztmtrack.getString("MAKTX").trim()
										+ "','"
										+ ztmtrack.getString("WERKS").trim()
										+ "','"
										+ ztmtrack.getString("LGORT").trim()
										+ "','"
										+ ztmtrack.getString("LGOBE").trim()
										+ "','"
										+ ztmtrack.getString("LABST").trim()
										+ "','"
										+ ztmtrack.getString("MEINS").trim()
										+ "',sysdate)";
								this.getDataCentre().update(sql);
							} else {
								sql = "update sale_sap_inventory set qty="
										+ ztmtrack.getString("LABST").trim()
										+ ",update_time=sysdate "
										+ " where  erp_code='" + matnr + "'"
										+ " and lgort='"
										+ ztmtrack.getString("LGORT").trim()
										+ "'";
								this.getDataCentre().update(sql);
							}

						}

					}
				}

			} catch (Exception ex) {

				ex.printStackTrace();

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}
	}

	*//**
	 * 读1500整机数据
	 * 
	 * @throws Exception
	 * *//*
	public void getZRFC_SCM_READ_MM03(String item_code, int tblx)
			throws Exception {
		// tblx==1 同步整机 tblx==2 同步单内机 tblx==3 同步单外机 tblx==4 同步PDM标机信息
		String sql = "";

		if (tblx == 1 || tblx == 2 || tblx == 3 || tblx == 5) {
			if (this.db_connect(SCM_MM03) == 2) {

				JCO.Function function = null;
				JCO.Table ztmtrack = null;
				try {

					getConnection();

					function = createFunction(SCM_MM03); // 取物料数据表

					*//**
					 *输入要读取物料号码
					 * *//*

					JCO.Structure ip_vkorg = function.getImportParameterList()
							.getStructure("IS_VKORG"); // 销售组织+分销渠道输入条件
					ip_vkorg.setValue("1100", "VKORG");// 销售组织
					ip_vkorg.setValue("", "VTWEG");// 分销渠道
					JCO.ParameterList input = function.getImportParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
					input.setValue("", "IV_LGORT");// 库存地点
					input.setValue("", "IV_MAXRECORDS");// 限制列表的长度

					JCO.ParameterList list = function.getTableParameterList();
					// 物料输入表
					JCO.Table it_matnr = list.getTable("IT_MATNR"); // 是一个内表。
					it_matnr.appendRow();
					it_matnr.setRow(0);
					it_matnr.setValue("I", "SIGN");
					it_matnr.setValue("EQ", "OPTION");
					it_matnr.setValue(item_code, "LOW");
					it_matnr.setValue("", "HIGH");

					// 工厂输入表
					JCO.Table it_werks = list.getTable("IT_WERKS"); // 是一个内表。
					it_werks.appendRow();
					it_werks.setRow(0);
					it_werks.setValue("I", "SIGN");
					it_werks.setValue("EQ", "OPTION");
					it_werks.setValue("1100", "LOW");
					it_werks.setValue("", "HIGH");

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}
					mConnection.execute(function);

					ztmtrack = list.getTable("ET_OUTPUT1"); // 是一个内表。

					if (ztmtrack.getNumRows() > 0) {
						for (int i = 0; i < ztmtrack.getNumRows(); i++) {
							ztmtrack.setRow(i);// 指定行
							if (tblx == 1) {
								if (getZRFC_SCM_READ_CS03(ztmtrack
										.getString("MATNR")) != null
										&& getZRFC_SCM_READ_CS03(ztmtrack
												.getString("MATNR")) != "") {

									getZRFC_SCM_READ_CS03(ztmtrack
											.getString("MATNR"));
									sql = "select nvl(item_h_id,0) from pro_item_header where item_h_code='"
											+ ztmtrack.getString("MATNR") + "'";
									int item_h_id = this.getDataCentre()
											.intSelect(sql);
									if (item_h_id == 0) {

										item_h_id = this.getDataCentre()
												.IDGenerator("pro_item_header",
														"item_h_id");
										sql = "insert into pro_item_header("
												+ " item_h_id,"
												+ " item_h_code ,"
												+ " item_h_name," + " h_spec,"
												+ " usable," + " creator,"
												+ " create_time," + " uom_id,"
												+ " uom_code," + " uom_name,"
												+ " entid,"
												+ " item_type,protype)values("
												+ item_h_id + ",'"
												+ ztmtrack.getString("MATNR")
												+ "','"
												+ ztmtrack.getString("MAKTX")
												+ "','"
												+ ztmtrack.getString("MAKTX")
												+ "'," + "2,'"
												+ this.getUserBean().UserId
												+ "'," + "sysdate," + "2,"
												+ "'02'," + "'套'," + "101,"
												+ "1,1)";
										this.getDataCentre().execute(sql);

										sql = " insert into pro_item(item_id,item_code,item_name,spec,usable,pro_type,uom_name,entid,uom_id,uom_code,item_h_id)"
												+ " select item_id,item_code,item_name,item_name,usable,pro_type,uom_name,101 entid,uom_id,uom_code,"
												+ item_h_id
												+ " item_h_id  from base_pro_item a "
												+ " where a.item_code in("
												+ getZRFC_SCM_READ_CS031(ztmtrack
														.getString("MATNR"))
												+ ")";
										this.getDataCentre().execute(sql);

									} else {

										*//**
										 * 
										 *当内外机编码不一致时用SAP最新的内外机编码替换OMS系统的内外机编码
										 * *//*
										String itemcode = "";

										sql = "update pro_item_header set "
												+ " item_h_name='"
												+ ztmtrack.getString("MAKTX")
												+ "'" + ",h_spec ='"
												+ ztmtrack.getString("MAKTX")
												+ "'" + ",update_time=sysdate "
												+ ",updator='"
												+ this.getUserBean().UserId
												+ "'" + " where  item_h_id="
												+ item_h_id;
										this.getDataCentre().update(sql);

										sql = " select count(*)  from pro_item a  where   a.item_code in("
												+ getZRFC_SCM_READ_CS031(ztmtrack
														.getString("MATNR"))
												+ ")"
												+ " and item_h_id="
												+ item_h_id;
										int count = this.getDataCentre()
												.intSelect(sql);

										sql = " select item_id,item_code,item_name,pro_type  from base_pro_item a "
												+ " where   a.item_code in("
												+ getZRFC_SCM_READ_CS031(ztmtrack
														.getString("MATNR"))
												+ ")";
										Vector vc_nj = this.getDataCentre()
												.multiRowSelect(sql);
										if (vc_nj.size() > 0 && count > 0) {
											for (int t = 0; t < vc_nj.size(); t++) {
												Hashtable htnwj = (Hashtable) vc_nj
														.elementAt(t);
												itemcode = (String) htnwj
														.get("item_code");
												String itemname = (String) htnwj
														.get("item_name");
												int pro_type = Integer
														.parseInt((String) htnwj
																.get("pro_type"));
												int item_id = Integer
														.parseInt((String) htnwj
																.get("item_id"));

												sql = " select count(*)  from pro_item a  where "
														+ " item_id="
														+ item_id
														+ " and item_h_id="
														+ item_h_id;
												int count1 = this
														.getDataCentre()
														.intSelect(sql);
												if (count1 > 0) {
													if (itemcode != null
															&& itemcode != "") {
														sql = "update pro_item set item_code='"
																+ itemcode
																+ "'"
																+ ",item_name='"
																+ itemname
																+ "'"
																+ ",spec='"
																+ itemname
																+ "'"
																+ ",pro_type="
																+ pro_type
																+ ",entid=101 "
																+ " where item_id="
																+ item_id
																+ " and item_h_id="
																+ item_h_id;
														this.getDataCentre()
																.update(sql);
													}
												} else {

													sql = " delete pro_item where item_code='"
															+ itemcode
															+ "'"
															+ " and item_h_id="
															+ item_h_id;
													this.getDataCentre()
															.delete(sql);

													sql = " insert into pro_item(item_id,item_code,item_name,spec,usable,pro_type,uom_name,entid,uom_id,uom_code,item_h_id)"
															+ " select item_id,item_code,item_name,item_name,usable,pro_type,uom_name,101 entid,uom_id,uom_code,"
															+ item_h_id
															+ " item_h_id  from base_pro_item a "
															+ " where a.item_code='"
															+ itemcode + "'";
													this.getDataCentre()
															.execute(sql);
												}

											}
											sql = "update pro_item_header set usable=2 "
													+ " where item_h_code='"
													+ item_code + "'";
											this.getDataCentre().update(sql);

										} else if (vc_nj.size() > 0
												&& count == 0) {

											sql = " delete pro_item where item_code in("
													+ getZRFC_SCM_READ_CS031(ztmtrack
															.getString("MATNR"))
													+ ")"
													+ " and item_h_id="
													+ item_h_id;
											this.getDataCentre().delete(sql);

											sql = " insert into pro_item(item_id,item_code,item_name,usable,pro_type,uom_name,entid,uom_id,uom_code,item_h_id)"
													+ " select item_id,item_code,item_name,usable,pro_type,uom_name,entid,uom_id,uom_code,"
													+ item_h_id
													+ " item_h_id  from base_pro_item a "
													+ " where a.item_code in("
													+ getZRFC_SCM_READ_CS031(ztmtrack
															.getString("MATNR"))
													+ ")";
											this.getDataCentre().execute(sql);

											sql = "update pro_item_header set usable=2 "
													+ " where item_h_code='"
													+ item_code + "'";
											this.getDataCentre().update(sql);

										} else {
											throw new IllegalLogicException(
													"SAP内外机信息维护不完整!");
										}

									}

								}
							}
							if (tblx == 2 || tblx == 3 || tblx == 5) {

								if (tblx == 2 || tblx == 3) {

									sql = " select count(*) from psc_item where psc_item_code='"
											+ ztmtrack.getString("MATNR")
											+ "'"
											+ " and usable=2 ";
									if (this.getPdmDataCentre().intSelect(sql) == 0) {
										throw new IllegalLogicException("此机型:【"
												+ ztmtrack.getString("MATNR")
												+ "】在PDM中没有维护，不能同步！");
									}

								}

								sql = "select nvl(item_h_id,0) from pro_item_header where item_h_code='"
										+ ztmtrack.getString("MATNR") + "'";
								int item_h_id = this.getDataCentre().intSelect(
										sql);

								com.dmcrm.proman.Base_Pro_Item bp = new com.dmcrm.proman.Base_Pro_Item();
								bp.setParent(this);
								sql = "select nvl(Item_id,0)item_id from Base_Pro_Item where Item_Code='"
										+ ztmtrack.getString("MATNR") + "'";
								Hashtable ht = this.getDataCentre()
										.oneRowSelect(sql);
								if (ht == null || ht.size() == 0) {

									bp.Item_Code = ztmtrack.getString("MATNR");
									bp.Item_Name = ztmtrack.getString("MAKTX");
									bp.Usable = 2;
									bp.EntId = 101;
									bp.Item_Kind = 0;
									if (tblx == 5) {
										bp.Pro_Type = 4;
									} else {
										bp.Pro_Type = tblx;
									}

									bp.Uom_Code = "01";
									bp.Uom_Id = 43;
									bp.Uom_Name = "台";
									bp.doInsert();
								} else {
									bp.Item_Id = Integer.parseInt((String) ht
											.get("item_id"));
									bp.Item_Code = ztmtrack.getString("MATNR");
									bp.Item_Name = ztmtrack.getString("MAKTX");
									bp.Usable = 2;
									bp.EntId = 101;
									bp.Item_Kind = 0;
									if (tblx == 5) {
										bp.Pro_Type = 4;
									} else {
										bp.Pro_Type = tblx;
									}
									bp.Uom_Code = "01";
									bp.Uom_Id = 43;
									bp.Uom_Name = "台";
									bp.doUpdate();
								}

								if (item_h_id == 0) {
									item_h_id = this.getDataCentre()
											.IDGenerator("pro_item_header",
													"item_h_id");
									sql = "insert into pro_item_header("
											+ " item_h_id," + " item_h_code ,"
											+ " item_h_name," + " h_spec,"
											+ " usable," + " creator,"
											+ " create_time," + " uom_id,"
											+ " uom_code," + " uom_name,"
											+ " entid,"
											+ " item_type,protype)values("
											+ item_h_id + ",'"
											+ ztmtrack.getString("MATNR")
											+ "','"
											+ ztmtrack.getString("MAKTX")
											+ "','"
											+ ztmtrack.getString("MAKTX")
											+ "'," + "2,'"
											+ this.getUserBean().UserId + "',"
											+ "sysdate," + "2," + "'02',"
											+ "'套'," + "101," + "1," + tblx
											+ ")";
									this.getDataCentre().execute(sql);

									sql = " insert into pro_item(item_id,item_code,item_name,spec,usable,pro_type,uom_name,entid,uom_id,uom_code,item_h_id)"
											+ " select item_id,item_code,item_name,item_name,usable,pro_type,uom_name,101 entid,uom_id,uom_code,"
											+ item_h_id
											+ " item_h_id  from base_pro_item a "
											+ " where a.item_code='"
											+ item_code + "'";
									this.getDataCentre().execute(sql);

								} else {

								}
							}

						}

					} else {
						throw new IllegalLogicException("此机型编码【" + item_code
								+ "】在SAP中不存在!");
					}

					if (tblx != 5) {
						this.doitem_header(item_code);
					}

				} catch (Exception ex) {
					ex.printStackTrace();
					throw new IllegalLogicException(ex.toString());
				} finally {

					// if (mConnection != null) {
					// mConnection.disconnect();
					// }

				}
			}

		} else if (tblx == 4) {
			this.doitem_header(item_code);
		} else if (tblx == 6) {
			this.doZnwj(item_code);
		}

	}

	*//**
	 * 读1500整机与内外机配套关系
	 * *//*
	public String getZRFC_SCM_READ_CS031(String ip_matnr)
			throws SinocpcException {

		String item_code = "";// 物料编码
		if (this.db_connect(SCM_CS03) == 2) {

			JCO.Function function = null;
			JCO.Table ztmtrack = null;
			try {
				// getConnection();
				function = createFunction(SCM_CS03); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_CS03 + "在sap中没有发现");
				} else {

					*//**
					 *输入要读取物料号码
					 * *//*
					JCO.ParameterList input = function.getImportParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
					input.setValue(ip_matnr, "IV_MATNR");// 物料号码
					input.setValue("1100", "IV_WERKS");// 工厂
					input.setValue("5", "IV_STLAN");// BOM用途
					input.setValue("01", "IV_STLAL");// 可选的BOM

					JCO.ParameterList list = function.getTableParameterList();

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}
					mConnection.execute(function);

					ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。

					if (ztmtrack.getNumRows() > 0) {
						for (int i = 0; i < ztmtrack.getNumRows(); i++) {
							ztmtrack.setRow(i);// 指定行
							if (item_code == "") {
								item_code = "'" + ztmtrack.getString("IDNRK")
										+ "'";// 物料编码
							} else {
								item_code = item_code + ",'"
										+ ztmtrack.getString("IDNRK") + "'";// 物料编码
							}

						}
					}
				}
			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				// if (mConnection != null) {
				// mConnection.disconnect();
				// }
			}
		}

		return item_code;

	}

	*//**
	 * 取PDM标机下内机的基本参数
	 * *//*
	public void doitem_header(String item_code_zh) throws SinocpcException {

		String sql = "";

		int item_type = 0;// 机型内型
		String trait_value = "";
		String value = "";
		String item_name = "";
		String item_no = "";
		String item_zj_code = "";
		int type_id = 0;

		sql = " select m.protype,n.item_code,n.pro_type from pro_item_header m,pro_item n where "
				+ " m.item_h_id=n.item_h_id "
				+ " and m.item_h_code='"
				+ item_code_zh + "'";
		Vector vc = this.getDataCentre().multiRowSelect(sql);
		if (vc.size() > 0) {
			for (int i = 0; i < vc.size(); i++) {
				Hashtable ht = (Hashtable) vc.elementAt(i);
				int protype = Integer.parseInt((String) ht.get("protype"));
				int pro_type = Integer.parseInt((String) ht.get("pro_type"));
				String item_code = (String) ht.get("item_code");
				// 移动空调
				if (protype == 4) {
					item_type = 4;
					type_id = 3;
				}
				// 内机,外机
				if (protype == 2 || protype == 3 || protype == 1) {
					item_type = pro_type;
				}
				if (protype != 4 && pro_type == 2) {
					type_id = 1;
				}
				if (protype != 4 && pro_type == 3) {
					type_id = 2;
				}

				sql = "select * from psc_item a where a.type_id=" + type_id
						+ " and a.psc_item_code='" + item_code + "'";
				Hashtable ht_n = this.getPdmDataCentre().oneRowSelect(sql);

				if (ht_n != null) {
					int usable = Integer.parseInt((String) ht_n.get("usable"));
					int psc_item_id = Integer.parseInt((String) ht_n
							.get("psc_item_id"));
					// 当内外机在PDM系统不可用，需要修改外销系统整机设置为不可用
					if (usable == 2) {
						// 取标机信息
						for (int n = 1; n <= 50; n++) {

							trait_value = "trait_value" + n;
							value = (String) ht_n.get(trait_value);// 取值PDM信息值

							sql = " select value_detail_desc from psc_type_trait_detail b "
									+ " where b.type_id="
									+ type_id
									+ " and b.trait_line_id="
									+ n
									+ " and b.value_detail_id=" + value;
							Hashtable hsvalue = this.getPdmDataCentre()
									.oneRowSelect(sql);
							String value_detail_desc = "";
							if (hsvalue != null) {
								value_detail_desc = (String) hsvalue
										.get("value_detail_desc");
							}
							sql = " select * from psc_type_tralt "
									+ " where item_no is not null and usable=2 and item_type="
									+ item_type + " and tralt_line_id=" + n;
							Hashtable ht_pro_n = this.getDataCentre()
									.oneRowSelect(sql);
							if (ht_pro_n != null) {
								item_name = (String) ht_pro_n.get("item_name");
								item_no = (String) ht_pro_n.get("item_no");
								item_zj_code = (String) ht_pro_n
										.get("item_zj_code");

								sql = " update " + item_name + " set "
										+ item_no + "='" + value_detail_desc
										+ "'" + " where " + item_zj_code
										+ " in ('" + item_code_zh + "','"
										+ item_code + "')";
								this.getDataCentre().update(sql);

							}

						}
						// 取内机平台,电源连接线长度,面板款式,遥控器
						String class_name = (String) ht_n.get("class_name");// 平台
						if (pro_type == 2) {

							sql = "update pro_item_header set item_platform='"
									+ class_name + "'" + " where item_h_code='"
									+ item_code_zh + "'";
							this.getDataCentre().update(sql);

							// 同步电源连接线长度、适用面板
							sql = "select * from psc_class_conf "
									+ " where  EntId = 1 "
									+ " and ((class_name like '"
									+ class_name
									+ "%'))"
									+ " and ((Version_Type = 1 and Version = 1) or (Version_Type = 2)) "
									+ " and ((INV_IDS like '%,1100,%') or (INV_IDS is null))";
							Hashtable htxp = this.getPdmDataCentre()
									.oneRowSelect(sql);
							if (htxp != null) {
								String dyljxcd = "";
								// sql=" select option_name from psc_class_conf_option where class_id="+Integer.parseInt((String)htxp.get("class_id"))
								// +" and version="+Integer.parseInt((String)htxp.get("version"))
								// +" and conf_name='电源连接线长度' "
								// +" and isdefault=1 ";

								sql = " select option_name "
										+ " from psc_class_conf_option m, psc_class_conf_line n "
										+ " where m.class_id = n.class_id "
										+ " and m.conf_id = n.conf_id "
										+ " and n.class_id ="
										+ Integer.parseInt((String) htxp
												.get("class_id"))
										+ " and m.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.USABLE = 2 "
										+ " and m.conf_name = '电源连接线长度' "
										+ " and m.isdefault = 1 ";

								dyljxcd = this.getPdmDataCentre()
										.strSelect(sql);
								if (dyljxcd != null && dyljxcd != "") {
									sql = " update pro_item set "
											+ "  nj_dyljx='" + dyljxcd + "'"
											+ " where item_code ='" + item_code
											+ "'";
									this.getDataCentre().update(sql);

									sql = " update pro_item_header set "
											+ "  dyljxcd='" + dyljxcd + "'"
											+ " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);

								} else {
									sql = " update pro_item set "
											+ "  nj_dyljx=''"
											+ " where item_code ='" + item_code
											+ "'";
									this.getDataCentre().update(sql);

									sql = " update pro_item_header set "
											+ "  dyljxcd=''"
											+ " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);
								}

								sql = " select option_name "
										+ " from psc_class_conf_option m, psc_class_conf_line n "
										+ " where m.class_id = n.class_id "
										+ " and m.conf_id = n.conf_id "
										+ " and n.class_id ="
										+ Integer.parseInt((String) htxp
												.get("class_id"))
										+ " and m.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.USABLE = 2 "
										+ " and m.conf_name = '面板款式' ";
								// +" and m.isdefault = 1 ";

								Vector vcxp = this.getPdmDataCentre()
										.multiRowSelect(sql);
								String stand_conf = "";
								if (vcxp.size() > 0) {
									for (int m = 0; m < vcxp.size(); m++) {
										Hashtable htmb = (Hashtable) vcxp
												.elementAt(m);
										if (stand_conf == "") {
											stand_conf = (String) htmb
													.get("option_name");
										} else {
											stand_conf = stand_conf
													+ ","
													+ (String) htmb
															.get("option_name");
										}
									}
								}
								if (stand_conf != null && stand_conf != "") {
									sql = " update pro_item_header set "
											+ "  stand_conf='" + stand_conf
											+ "'" + " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);

								} else {
									sql = " update pro_item_header set "
											+ "  stand_conf=''"
											+ "  where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);
								}

								sql = " select option_name "
										+ " from psc_class_conf_option m, psc_class_conf_line n "
										+ " where m.class_id = n.class_id "
										+ " and m.conf_id = n.conf_id "
										+ " and n.class_id ="
										+ Integer.parseInt((String) htxp
												.get("class_id"))
										+ " and m.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.USABLE = 2 "
										+ " and m.conf_name = '遥控器款式' "
										+ " and m.isdefault = 1 ";

								String trait_value3 = "";
								trait_value3 = this.getPdmDataCentre()
										.strSelect(sql);

								if (trait_value3 != null && trait_value3 != "") {
									sql = " update pro_item_header set "
											+ "  trait_value3='" + trait_value3
											+ "'" + " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);

								} else {
									sql = " update pro_item_header set "
											+ "  trait_value3=''"
											+ "  where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);
								}

							}

							*//**
							 *取内机电源连接线金额
							 * *//*
							if (this.dyljxcd_amt(item_code, 1) != null
									&& !this.dyljxcd_amt(item_code, 1).equals(
											"0")) {
								sql = " update pro_item " + " set dyljx_amt='"
										+ this.dyljxcd_amt(item_code, 1) + "'"
										+ " where item_code ='" + item_code
										+ "'";
								this.getDataCentre().update(sql);

								sql = " update pro_item_header "
										+ " set dyljxcd_amt='"
										+ this.dyljxcd_amt(item_code, 1) + "'"
										+ " where item_h_code ='"
										+ item_code_zh + "'";
								this.getDataCentre().update(sql);
							} else {

								if (this.dyljxcd_amt(item_code, 3) != null
										&& !this.dyljxcd_amt(item_code, 3)
												.equals("0")) {
									sql = " update pro_item "
											+ " set dyljx_amt='"
											+ this.dyljxcd_amt(item_code, 3)
											+ "'" + " where item_code ='"
											+ item_code + "'";
									this.getDataCentre().update(sql);

									sql = " update pro_item_header "
											+ " set dyljxcd_amt='"
											+ this.dyljxcd_amt(item_code, 3)
											+ "'" + " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);
								} else {
									sql = " update pro_item "
											+ " set dyljx_amt='0'"
											+ " where item_code ='" + item_code
											+ "'";
									this.getDataCentre().update(sql);

									sql = " update pro_item_header "
											+ " set dyljxcd_amt='0'"
											+ " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);
								}

							}

						}
						if (pro_type == 3) {
							// 同步连接管长度
							sql = "select * from psc_class_conf "
									+ " where  EntId = 1 "
									+ " and ((class_name like '"
									+ class_name
									+ "%'))"
									+ " and ((Version_Type = 1 and Version = 1) or (Version_Type = 2)) "
									+ " and ((INV_IDS like '%,1100,%') or (INV_IDS is null))";
							Hashtable htxp = this.getPdmDataCentre()
									.oneRowSelect(sql);
							if (htxp != null) {
								String conn_length = "";
								String in_prod_codes = "";
								String ex_prod_codes = "";

								sql = "select in_prod_codes,ex_prod_codes from psc_class_conf_line h"
										+ " where class_id ="
										+ Integer.parseInt((String) htxp
												.get("class_id"))
										+ " and version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and conf_name = '换连接管'";
								Hashtable htprod = this.getPdmDataCentre()
										.oneRowSelect(sql);
								if (htprod != null) {
									in_prod_codes = (String) htprod
											.get("in_prod_codes");
									ex_prod_codes = (String) htprod
											.get("ex_prod_codes");
								}

								sql = " select option_name "
										+ " from psc_class_conf_option m, psc_class_conf_line n "
										+ " where m.class_id = n.class_id "
										+ " and m.conf_id = n.conf_id "
										+ " and n.class_id ="
										+ Integer.parseInt((String) htxp
												.get("class_id"))
										+ " and m.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.version ="
										+ Integer.parseInt((String) htxp
												.get("version"))
										+ " and n.USABLE = 2 "
										+ " and m.conf_name = '换连接管' "
										+ " and m.isdefault = 1 ";

								if (ex_prod_codes != null
										&& ex_prod_codes != "") {
									sql += " and n.ex_prod_codes not like '%"
											+ item_code + "%'";
								}
								if (in_prod_codes != null
										&& in_prod_codes != "") {
									sql += " and n.in_prod_codes  like '%"
											+ item_code + "%'";
								}

								conn_length = this.getPdmDataCentre()
										.strSelect(sql);

								if (conn_length != null && conn_length != "") {
									sql = " update pro_item_header "
											+ " set conn_length='"
											+ conn_length + "'"
											+ " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);

								} else {
									sql = " update pro_item_header "
											+ " set conn_length=''"
											+ " where item_h_code ='"
											+ item_code_zh + "'";
									this.getDataCentre().update(sql);
								}

							}

							*//**
							 *取外机连接管金额
							 **//*
							if (this.dyljxcd_amt(item_code, 2) != null) {
								sql = " update pro_item_header "
										+ " set conn_length_amt='"
										+ this.dyljxcd_amt(item_code, 2) + "'"
										+ " where item_h_code ='"
										+ item_code_zh + "'";
								this.getDataCentre().update(sql);
							} else {
								sql = " update pro_item_header "
										+ " set conn_length_amt='0'"
										+ " where item_h_code ='"
										+ item_code_zh + "'";
								this.getDataCentre().update(sql);
							}

							*//**
							 *取外机电源连接线金额
							 * *//*

							if (this.dyljxcd_amt(item_code, 1) != null) {
								sql = " update pro_item_header "
										+ " set dyljxcd_amt=dyljxcd_amt+"
										+ this.dyljxcd_amt(item_code, 1)
										+ " where item_h_code ='"
										+ item_code_zh + "'";
								this.getDataCentre().update(sql);
							} else {
								sql = " update pro_item_header "
										+ " set dyljxcd_amt=dyljxcd_amt+0 "
										+ " where item_h_code ='"
										+ item_code_zh + "'";
								this.getDataCentre().update(sql);
							}
						}

					} else {

						sql = " update pro_item_header set usable=1 "
								+ " where item_h_id in( "
								+ " select nvl(item_h_id,0)item_h_id from pro_item where item_code='"
								+ item_code + "'" + " )";
						this.getDataCentre().update(sql);

					}
				}

			}
			*//**
			 *算体积
			 * *//*
			sql = " select substr(bzcc,0,instr(bzcc,'(')-1)tj1,substr(bzcc,0,instr(bzcc,'（')-1)tj2,item_h_id,item_code "
					+ " from pro_item where item_h_id=(select  item_h_id from pro_item_header where usable=2 and item_h_code='"
					+ item_code_zh + "')";
			Vector vcline = this.getDataCentre().multiRowSelect(sql);
			String tj1 = "";
			String tj2 = "";
			if (vcline.size() > 0) {
				for (int e = 0; e < vc.size(); e++) {
					Hashtable htline = (Hashtable) vcline.elementAt(e);
					// 同步内机体积

					tj1 = (String) htline.get("tj1").toString().trim();

					tj2 = (String) htline.get("tj2").toString().trim();
					String volume = "";

					if (tj1 != null && tj1 != "") {

						sql = "select round(" + tj1
								+ "*0.001*0.001*0.001,8) from dual  ";
						volume = this.getDataCentre().strSelect(sql);
						if (volume != null && volume != "") {
							sql = " update pro_item "
									+ " set volume='"
									+ volume
									+ "'"
									+ " where item_code='"
									+ (String) htline.get("item_code")
									+ "'"
									+ " and item_h_id="
									+ Integer.parseInt((String) htline
											.get("item_h_id"));
							this.getDataCentre().update(sql);
						}

					}
					if (tj2 != null && tj2 != "") {
						sql = "select round(" + tj2
								+ "*0.001*0.001*0.001,8) from dual ";
						volume = this.getDataCentre().strSelect(sql);
						if (volume != null && volume != "") {
							sql = " update pro_item "
									+ " set volume='"
									+ volume
									+ "'"
									+ " where item_code='"
									+ (String) htline.get("item_code")
									+ "'"
									+ " and item_h_id="
									+ Integer.parseInt((String) htline
											.get("item_h_id"));
							this.getDataCentre().update(sql);
						}

					}

				}
			}
		}

	}

	*//**
	 *取PDM内机电源连接线、 外机电源连接管金额
	 * *//*
	public String dyljxcd_amt(String item_code, int flag)
			throws SinocpcException {
		String amt = "0";
		try {
			String sql = "select itemid from cpcitem where invorgid=1100 and  itemcode='"
					+ item_code + "'";
			int psc_item_id = this.getPdmDataCentre().intSelect(sql);
			if (psc_item_id > 0) {

				sql = "  select dictvalue  from cpcdict where dictcode='USD_EXCHANGE_RATE' ";
				String temp1 = this.getDataCentre().strSelect(sql);
				if (temp1 == null || temp1.length() == 0)
					temp1 = "6.32";
				BigDecimal us_year_rate = new BigDecimal(temp1);

				if (flag == 1) {
					sql = "select nvl(round(sum(price)*1.03*1.01*1.3/("
							+ us_year_rate
							+ "),1 ),0) from ( select a.itemid item_id,sum(p.price*b.qty) price,a.l flag from ( "
							+ " select b.item_id,b.price from psc_item_cost a,psc_item_cost_line b where a.cost_id = b.cost_id  "
							+ " and a.psc_item_id ="
							+ psc_item_id
							+ " and a.is_newest = 2 "
							+ " )p,( "
							+ " select item.itemid, item.itemcode,  psc_str_mult(sys_connect_by_path(1 * bomd.qty/decode(item1.stockunit,item1.itemunit,1,item1.weight) , '*')) qty, "
							+ " level l,sys_connect_by_path(item.itemid , '/') path "
							+ " from cpcbom bom, cpcbomd bomd, cpcitem item, cpcitem item1 "
							+ " where bom.bomid = bomd.bomid and bomd.itemid = item.itemid and bom.asmid = item1.itemid "
							+ " and ( connect_by_isleaf = 1 or level = 1) "
							+ " start with bom.asmid ="
							+ psc_item_id
							+ "  and bom.IsMainBom = 'Y'   "
							+ " connect by prior bomd.itemid = bom.asmid    and bom.IsMainBom = 'Y' "
							+ " )a,( "
							+ " select item.itemid, item.itemcode,  psc_str_mult(sys_connect_by_path(1 * bomd.qty/decode(item1.stockunit,item1.itemunit,1,item1.weight) , '*')) qty, "
							+ " level l,sys_connect_by_path(item.itemid , '/') path "
							+ " from cpcbom bom, cpcbomd bomd, cpcitem item, cpcitem item1 "
							+ " where bom.bomid = bomd.bomid and bomd.itemid = item.itemid and bom.asmid = item1.itemid "
							+ " and ( connect_by_isleaf = 1 or level = 1) "
							+ " start with bom.asmid ="
							+ psc_item_id
							+ " and bom.IsMainBom = 'Y'   "
							+ " connect by prior bomd.itemid = bom.asmid    and bom.IsMainBom = 'Y' "
							+ " )b "
							+ " where a.l = 1 and b.l <> 1 "
							+ " and a.path = substr(b.path,0,length(a.path)) and b.itemid = p.item_id  "
							+ " group by a.itemid, a.l"
							+ " union all "
							+ " select b.item_id,total_price,0 flag from psc_item_cost a,psc_item_cost_line b ,cpcbom,cpcbomd "
							+ " where a.cost_id = b.cost_id and a.psc_item_id ="
							+ psc_item_id
							+ " and a.is_newest = 2 and ismainbom = 'Y' "
							+ " and a.psc_item_id = cpcbom.asmid "
							+ " and cpcbom.bomid = cpcbomd.bomid "
							+ " and cpcbomd.itemid = b.item_id "
							+ " )a ,(select a.itemid,qty,cpcitem.itemcode,cpcitem.itemname,cpcitem.itemunit from ( "
							+ " select itemid,qty from   cpcbom ,cpcbomd  where "
							+ " cpcbom.bomid = cpcbomd.bomid  and ismainbom = 'Y'"
							+ " and cpcbom.asmid ="
							+ psc_item_id
							+ " )a,cpcitem"
							+ " where "
							+ " a.itemid=cpcitem.itemid"
							+ " and cpcitem.invorgid=1100"
							+ " )cpcitem  "
							+ " where a.item_id=cpcitem.itemid "
							+ " and  cpcitem.itemname like'%电源连接线%' and  cpcitem.itemname not like'%无电源连接线%' and  cpcitem.itemname not like'%电源连接线压板%' "
							+ " and  cpcitem.itemname not like'%去电源连接线%' ";
					amt = this.getPdmDataCentre().strSelect(sql);
				} else if (flag == 2) {
					sql = "select nvl(round(sum(price)*1.03*1.01*1.3/("
							+ us_year_rate
							+ "),1 ),0) from ( select a.itemid item_id,sum(p.price*b.qty) price,a.l flag from ( "
							+ " select b.item_id,b.price from psc_item_cost a,psc_item_cost_line b where a.cost_id = b.cost_id  "
							+ " and a.psc_item_id ="
							+ psc_item_id
							+ " and a.is_newest = 2 "
							+ " )p,( "
							+ " select item.itemid, item.itemcode,  psc_str_mult(sys_connect_by_path(1 * bomd.qty/decode(item1.stockunit,item1.itemunit,1,item1.weight) , '*')) qty, "
							+ " level l,sys_connect_by_path(item.itemid , '/') path "
							+ " from cpcbom bom, cpcbomd bomd, cpcitem item, cpcitem item1 "
							+ " where bom.bomid = bomd.bomid and bomd.itemid = item.itemid and bom.asmid = item1.itemid "
							+ " and ( connect_by_isleaf = 1 or level = 1) "
							+ " start with bom.asmid ="
							+ psc_item_id
							+ "  and bom.IsMainBom = 'Y'   "
							+ " connect by prior bomd.itemid = bom.asmid    and bom.IsMainBom = 'Y' "
							+ " )a,( "
							+ " select item.itemid, item.itemcode,  psc_str_mult(sys_connect_by_path(1 * bomd.qty/decode(item1.stockunit,item1.itemunit,1,item1.weight) , '*')) qty, "
							+ " level l,sys_connect_by_path(item.itemid , '/') path "
							+ " from cpcbom bom, cpcbomd bomd, cpcitem item, cpcitem item1 "
							+ " where bom.bomid = bomd.bomid and bomd.itemid = item.itemid and bom.asmid = item1.itemid "
							+ " and ( connect_by_isleaf = 1 or level = 1) "
							+ " start with bom.asmid ="
							+ psc_item_id
							+ " and bom.IsMainBom = 'Y'   "
							+ " connect by prior bomd.itemid = bom.asmid    and bom.IsMainBom = 'Y' "
							+ " )b "
							+ " where a.l = 1 and b.l <> 1 "
							+ " and a.path = substr(b.path,0,length(a.path)) and b.itemid = p.item_id  "
							+ " group by a.itemid, a.l"
							+ " union all "
							+ " select b.item_id,total_price,0 flag from psc_item_cost a,psc_item_cost_line b ,cpcbom,cpcbomd "
							+ " where a.cost_id = b.cost_id and a.psc_item_id ="
							+ psc_item_id
							+ " and a.is_newest = 2 and ismainbom = 'Y' "
							+ " and a.psc_item_id = cpcbom.asmid "
							+ " and cpcbom.bomid = cpcbomd.bomid "
							+ " and cpcbomd.itemid = b.item_id "
							+ " )a ,(select a.itemid,qty,cpcitem.itemcode,cpcitem.itemname,cpcitem.itemunit from ( "
							+ " select itemid,qty from   cpcbom ,cpcbomd  where "
							+ " cpcbom.bomid = cpcbomd.bomid  and ismainbom = 'Y'"
							+ " and cpcbom.asmid ="
							+ psc_item_id
							+ " )a,cpcitem"
							+ " where "
							+ " a.itemid=cpcitem.itemid"
							+ " and cpcitem.invorgid=1100"
							+ " )cpcitem  "
							+ " where a.item_id=cpcitem.itemid "
							+ " and cpcitem.itemname like '%连接管组件%' and cpcitem.itemname not like '%橡塑%' ";
					amt = this.getPdmDataCentre().strSelect(sql);

				} else if (flag == 3) {
					sql = " select nvl(round(sum(total_price)*1.03*1.01*1.3/("
							+ us_year_rate
							+ "),1 ),0) "
							+ " from psc_item_cost_line a, cpcitem b,psc_item_cost c "
							+ " where a.cost_id=c.cost_id "
							+ " and a.item_id = b.itemid "
							+ " and c.is_newest=2 " + " and c.psc_item_id="
							+ psc_item_id + " and  b.itemname like'%电源连接线%'  "
							+ " and  b.itemname not like'%无电源连接线%'  "
							+ " and  b.itemname not like'%电源连接线压板%'   "
							+ " and  b.itemname not like'%去电源连接线%' ";
					amt = this.getPdmDataCentre().strSelect(sql);
				}
			}

		} catch (Exception ex) {
			System.out.println("同步失败");
		}
		return amt;
	}

	// 根据提供的函数名称创建一个函数
	public JCO.Function createFunction(String name)
			throws IllegalLogicException {
		// try {
		// 对象包含着某个特定的RFM元数据
		IFunctionTemplate ft = null;
		if (name != null) {
			if (mRepository == null) {
				throw new IllegalLogicException("mRepository为空");
			}
			ft = mRepository.getFunctionTemplate(name.toUpperCase());

			if (ft == null) {
				throw new IllegalLogicException("ft为空");
			}
		} else {
			throw new IllegalLogicException("ft为空");
		}

		return ft.getFunction();

	}

	*//**
	 * 发货通知单审核最后一步调用此方法传SAP生成SAP的内部订单、销售订单、交货单、发货单
	 * *//*
	public void doOut_Header(int notice_id) throws SinocpcException {

		String sql = "";
		*//**
		 * 判断形式发票类型除内销以外都写SAP:sale_order_type
		 *//*
		// sql="select wm_concat( distinct iv_vbeln)iv_vbeln "
		// +" from sale_ship_notice_header a,sale_ship_item_line3 b,sale_prod_sap c "
		// +" where a.notice_id=b.notice_id "
		// +" and b.erp_code=c.erp_code "
		// +" and b.prod_id=c.prod_id "
		// +" and nvl(out_qty,0)>0 and b.prod_line_id=c.prod_line_id "
		//		       
		// +" and a.notice_id="+notice_id;
		// String iv_vbeln=this.getDataCentre().strSelect(sql);
		//		        		
		// sql=" select to_char(b.check_time,'yyyymmdd') check_time,notice_no,pi_no,pi_id,notice_id, "
		// +" to_char(sysdate,'yyyymmdd')iv_date "
		// +" from  sale_ship_notice_header b "
		// +" where  b.notice_id="+notice_id;
		// Hashtable ht= this.getDataCentre().oneRowSelect(sql);
		// Vector vc;
		// if(ht!=null){
		//			         
		// sql=" select b.erp_code,b.out_qty,iv_vbeln,c.seq,to_char(a.actual_ship_date,'yyyymmdd') check_time,b.prod_line_id "
		// +" from sale_ship_notice_header a,sale_ship_item_line3 b,sale_prod_sap c "
		// +" where a.notice_id=b.notice_id "
		// +" and b.erp_code=c.erp_code  and b.prod_id=c.prod_id "
		// +" and nvl(out_qty,0)>0 and b.prod_line_id=c.prod_line_id "
		// +" and a.notice_id="+notice_id;
		// vc=this.getDataCentre().multiRowSelect(sql);
		//			    	 
		// if(vc.size()>0){
		// //交货单
		// sql="select count(*) from sale_ship_notice_sap_line where   notice_id="+notice_id;
		// if(this.getDataCentre().intSelect(sql)==0){
		// this.ZIF_OMS_DELIVERY_CREATE_VL01N(ht, vc,iv_vbeln);
		// }
		//			    					    		 
		// sql="select delorder_sap from sale_ship_notice_sap_line where delorder_sap is not null and  notice_id="+notice_id;
		// Hashtable htdelorder_sap= this.getDataCentre().oneRowSelect(sql);
		//						 
		// if(htdelorder_sap!=null){
		// //发货过账
		// this.ZIF_OMS_DELIVERY_POST_VL02N(ht,(String)htdelorder_sap.get("delorder_sap"));
		// }
		//							 
		// }
		//			    							    
		// }

		// 按发货通知单中的商检批次分别在SAP生成发货通知单
		Vector vc;
		sql = " select to_char(b.check_time,'yyyymmdd') check_time,notice_no,pi_no,pi_id,notice_id, "
				+ " to_char(sysdate,'yyyymmdd')iv_date "
				+ " from  sale_ship_notice_header b "
				+ " where  b.notice_id="
				+ notice_id;
		Hashtable ht = this.getDataCentre().oneRowSelect(sql);

		sql = "select distinct iv_vbeln iv_vbeln "
				+ " from sale_ship_notice_header a,sale_ship_item_line3 b,sale_prod_sap c "
				+ " where a.notice_id=b.notice_id "
				+ " and b.erp_code=c.erp_code " + " and b.prod_id=c.prod_id "
				+ " and nvl(out_qty,0)>0 and b.prod_line_id=c.prod_line_id "
				+ " and a.notice_id=" + notice_id;
		Vector vc_iv_vbeln = this.getDataCentre().multiRowSelect(sql);
		if (vc_iv_vbeln.size() > 0) {
			for (int i = 0; i < vc_iv_vbeln.size(); i++) {
				Hashtable ht_iv_vbeln = (Hashtable) vc_iv_vbeln.elementAt(i);
				String iv_vbeln = (String) ht_iv_vbeln.get("iv_vbeln");
				sql = " select b.erp_code,b.out_qty,iv_vbeln,c.seq,to_char(a.actual_ship_date,'yyyymmdd') check_time,b.prod_line_id "
						+ " from sale_ship_notice_header a,sale_ship_item_line3 b,sale_prod_sap c "
						+ " where a.notice_id=b.notice_id "
						+ " and b.erp_code=c.erp_code  and b.prod_id=c.prod_id "
						+ " and nvl(out_qty,0)>0 and b.prod_line_id=c.prod_line_id "
						+ " and a.notice_id="
						+ notice_id
						+ " and iv_vbeln='"
						+ iv_vbeln + "'" + " order by  c.seq ";
				vc = this.getDataCentre().multiRowSelect(sql);
				if (vc.size() > 0) {
					// 交货单
					sql = "select count(*) from sale_ship_notice_sap_line where   notice_id="
							+ notice_id
							+ " and interior_sap='"
							+ iv_vbeln
							+ "'";
					if (this.getDataCentre().intSelect(sql) == 0) {
						this.ZIF_OMS_DELIVERY_CREATE_VL01N(ht, vc, iv_vbeln);
					}
				}
			}
		}
		// 发货过账
		sql = "select delorder_sap from sale_ship_notice_sap_line where delorder_sap is not null and  notice_id="
				+ notice_id;
		Vector vcfh = this.getDataCentre().multiRowSelect(sql);
		if (vcfh.size() > 0) {
			for (int i = 0; i < vcfh.size(); i++) {
				Hashtable htdelorder_sap = (Hashtable) vcfh.elementAt(i);
				String delorder_sap = (String) htdelorder_sap
						.get("delorder_sap");
				sql = " select count(*) from sale_ship_notice_sap_line where outno_sap is not null and notice_id="
						+ notice_id
						+ " and delorder_sap='"
						+ delorder_sap
						+ "'";
				if (this.getDataCentre().intSelect(sql) == 0) {
					this.ZIF_OMS_DELIVERY_POST_VL02N(ht,
							(String) htdelorder_sap.get("delorder_sap"));
				}
			}
		}

	}

	*//**
	 * 读开票凭证
	 * 
	 * @throws SinocpcException
	 * *//*
	public void getZAUXSCMPZ(String strDate, String endDate)
			throws SinocpcException {

		if (this.db_connect(SCM_AUX) == 2) {
			String sql = "";
			JCO.Function function = null;
			JCO.Table ztmtrack = null;
			try {
				getConnection();
				function = createFunction(SCM_AUX);
				if (function == null) {
					System.out.println(SCM_AUX + "在sap中没有发现");
				} else {

					JCO.ParameterList input = function.getImportParameterList();
					input.setValue("1130", "IV_BUKRS");// 公司代码
					input.setValue("1131", "IV_VKORG");// 销售组织

					JCO.ParameterList list = function.getTableParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
					ztmtrack = list.getTable("ET_BSEG"); // 是一个内表。
					*//**
					 * 输入凭证日期
					 * *//*
					// JCO.Table it_werks = list.getTable("P_BLDAT");
					// it_werks.appendRow();
					// it_werks.setRow(0);
					// it_werks.setValue("I", "SIGN");
					// it_werks.setValue("BT", "OPTION");
					// it_werks.setValue(strDate, "LOW");
					// it_werks.setValue(strDate, "HIGH");

					*//**
					 * 输入开票日期
					 * *//*
					JCO.Table it_lgort = list.getTable("IT_FKDAT");

					it_lgort.appendRow();
					it_lgort.setRow(0);
					it_lgort.setValue("I", "SIGN");
					it_lgort.setValue("BT", "OPTION");
					it_lgort.setValue(strDate, "LOW");
					it_lgort.setValue(endDate, "HIGH");

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}
					mConnection.execute(function);

					System.out.println("ztmtrack.getNumRows() = "
							+ ztmtrack.getNumRows());
					if (ztmtrack.getNumRows() > 0) {
						for (int i = 0; i < ztmtrack.getNumRows(); i++) {
							ztmtrack.setRow(i);// 指定行
							String budat = ztmtrack.getString("BUDAT");
							String invoice_no = ztmtrack.getString("BELNR");
							String fact_invoice_no = ztmtrack
									.getString("BELNR");

							String pi_no = ztmtrack.getString("XBLNR");
							String invoice_amt = ztmtrack.getString("WRBTR");
							String cust_code = ztmtrack.getString("KUNNR");
							String currency_code = ztmtrack.getString("WAERS");
							String bldat = ztmtrack.getString("BLDAT");

							String dmbtr = ztmtrack.getString("DMBTR");
							String shkzg = ztmtrack.getString("SHKZG");
							String pay_condition = ztmtrack.getString("ZTERM");
							int inv_type = 1;
							int zuzhi = 2;
							int orgid = 0;
							String orgcode = "";
							String orgname = "";
							String idpath = "";
							if (shkzg.equals("H")) {
								invoice_amt = "-" + invoice_amt;
								dmbtr = "-" + dmbtr;
								inv_type = 2;
							}

							if (inv_type == 1) {
								sql = "select * from customer where sap_code='"
										+ cust_code.substring(4, 10) + "'";
								Hashtable htcode = this.getDataCentre()
										.oneRowSelect(sql);
								if (htcode != null) {
									String other_org_ids = (String) htcode
											.get("other_org_ids");
									sql = "select * from cpcorg h "
											+ " where ','||orgid||',' like '%"
											+ other_org_ids + "%' "
											+ " and h.superid=223 "
											+ " and rownum=1 ";
									Hashtable htorg = this.getDataCentre()
											.oneRowSelect(sql);
									if (htorg != null) {
										orgid = Integer.parseInt((String) htorg
												.get("orgid"));
										orgname = (String) htorg.get("orgname");
										orgcode = (String) htorg.get("code");
										idpath = (String) htorg.get("idpath");
									}
								} else {
									orgid = Integer.parseInt((String) htcode
											.get("org_id"));
									orgname = (String) htcode.get("org_name");
									orgcode = (String) htcode.get("org_code");
									idpath = (String) htcode.get("idpath");
								}
							}

							int invoice_id = getDao().IDGenerator(
									"bill_invoice_bl_header", "invoice_id");
							sql = " insert into bill_invoice_bl_header ( "
									+ " invoice_id, "
									+ " invoice_no, "
									+ " fact_invoice_no, "
									+ " creator, "
									+ " create_time, "
									+ " pi_no, "
									+ " invoice_amt, "
									+ " dmbtr,   "
									+ " currency_code , "
									+ " cust_code,"
									+ " bldat, "
									+ " entid , "
									+ " budat, "
									+ " is_qc,"
									+ " pay_condition,  "
									+ " inv_type,orgid,orgcode,orgname,idpath,zuzhi)values("
									+ +invoice_id
									+ ",'"
									+ invoice_no
									+ "','"
									+ fact_invoice_no
									+ "','"
									+ "接口导入',"
									+ "sysdate,'"
									+ pi_no
									+ "',"
									+ invoice_amt
									+ ","
									+ dmbtr
									+ ",'"
									+ currency_code
									+ "','"
									+ cust_code
									+ "',"
									+ "to_date('"
									+ bldat
									+ "','yyyy-mm-dd'),"
									+ "101,"
									+ "to_date('"
									+ budat
									+ "','yyyy-mm-dd'),"
									+ "1,'"
									+ pay_condition
									+ "',"
									+ inv_type
									+ ","
									+ orgid
									+ ",'"
									+ orgcode
									+ "','"
									+ orgname
									+ "','"
									+ idpath
									+ "',"
									+ zuzhi
									+ ")";
							this.getDataCentre().execute(sql);

						}

					}

					SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
					java.util.Calendar calendar = java.util.Calendar
							.getInstance();
					String strDate1 = df.format(calendar.getTime());

					sql = "update   bill_invoice_bl_header a set "
							+ " (cust_id,cust_name,cust_code)=(  "
							+ " select * from ( "
							+ " select cust_id,cust_name ,sap_code from customer where sap_code  in(  "
							+ " select substr(cust_code,5) from  bill_invoice_bl_header  "
							+ " ) )b "
							+ " where substr(a.cust_code,5)=b.sap_code "
							+ " ) " + " where a.cust_code is not null "
							+ " and to_char(a.create_time,'yyyymmdd')='"
							+ strDate1 + "'";
					this.getDataCentre().update(sql);

					sql = " update   bill_invoice_bl_header a set "
							+ " (a.currency_id,a.currency_name)=(  "
							+ " select b.currency_id,b.currency_name from base_currency b "
							+ " where b.currency_code=a.currency_code " + " ) "
							+ " where a.currency_code is not null "
							+ " and to_char(a.create_time,'yyyymmdd')='"
							+ strDate1 + "'";
					this.getDataCentre().update(sql);

					sql = " update bill_invoice_bl_header m set ( "
							+ " cust_id,cust_name,cust_code,currency_id,currency_code,currency_name,pay_condition,orgid,orgcode,orgname,idpath)=( "
							+ " select n.cust_id,n.cust_name,n.cust_code,n.currency_id,n.currency_code, "
							+ " n.currency_name,n.pay_condition,n.orgid,n.orgcode,n.orgname,n.idpath from bill_invoice_bl_header n  "
							+ " where n.cust_code is not null "
							+ " and m.invoice_no=n.invoice_no) "
							+ " where m.cust_code is  null  "
							+ " and to_char(m.create_time,'yyyymmdd')='"
							+ strDate1 + "'";
					this.getDataCentre().update(sql);

				}

			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}

	}

	public void getZRFC_OMS_GET_AC(String strDate) throws SinocpcException {

	}

	*//**
	 * 创建销售客户 XD01
	 * *//*
	public void putZRFC_SCM_WRITE_XD01(String erp_code, int custtype,
			int up_in, String sap_code) throws SinocpcException {

		String sql = "";
		String ev_subrc = "";
		if (this.db_connect(SCM_XD01) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				String name = "";
				function = createFunction(SCM_XD01);

				if (function == null) {
					System.out.println(name + "在sap中没有发现");
				} else {

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*

					sql = "select m.*,n.zone_code sap_zone_code,n.sap_org_code,substr(m.cust_name,1,12)SORT1, "
							+ " case when substr(m.cust_code,1,1)='W'then '1122010020'else "
							+ " '1122010020'end AKONT, "
							+ " case when substr(m.cust_code,1,1)='W'then '02'else "
							+ " '01'end KTGRD, "
							+ " case when substr(m.cust_code,1,1)='W'then '0'else "
							+ " '1'end taxkd, "
							+ " case when  c.superid<>223 then '1100' else'1120' end vwerk, "
							+ " case when  c.superid<>223 then '1130' else'1131' end vkorg, "
							+ " case when substr(m.cust_code,1,1)='W' then 'C003' else 'C003' end ktokd "
							+ " from customer m,base_contract n ,cpcorg c"
							+ " where m.org_id=n.org_id and m.org_id=c.orgid "
							+ " and cust_code='" + erp_code + "'";

					Hashtable ht = this.getDataCentre().oneRowSelect(sql);
					JCO.Structure ip_header = function.getImportParameterList()
							.getStructure("IS_CUSTOMER"); // 获取import抬头结构

					sql = " select distinct p.pay_condition from customer_payment_type m,payment_type p where "
							+ " p.payment_type_id=m.payment_type_id "
							+ " and cust_code='"
							+ erp_code
							+ "'"
							+ " and rownum=1 " + " order by p.pay_condition ";
					String pay_condition = this.getDataCentre().strSelect(sql);

					sql = " select dictname from cpcdict "
							+ " where dictcode like '%Cust_Level%'  "
							+ " and  dictvalue="
							+ Integer.parseInt((String) ht.get("cust_level"));
					String dictname = this.getDataCentre().strSelect(sql);

					if (ht != null) {
						if (up_in == 2) {
							ip_header.setValue((String) ht.get("sap_code"),
									"KUNNR");// 购货方编号
						}
						ip_header.setValue("1130", "BUKRS");// 公司代码 进出口:1130
															// 香港:1500
						ip_header.setValue((String) ht.get("vkorg"), "VKORG");// 销售组织
																				// 进出口:1130
																				// 香港:1500
						ip_header.setValue("00", "VTWEG");// 分销渠道
						ip_header.setValue("00", "SPART");// 部门
						ip_header.setValue((String) ht.get("ktokd"), "KTOKD");// 客户帐户组
						ip_header.setValue("0003", "TITLE");// 标题
						ip_header.setValue((String) ht.get("cust_name"),
								"NAME1");// 名称 1
						ip_header.setValue((String) ht.get("sort1"), "SORT1");// 搜索项目
																				// 1
						ip_header.setValue("", "STREET1");// 街道名
						ip_header.setValue("ZH", "SPRAS");// 语言
						ip_header.setValue("010", "CITY1");// 城市
						ip_header.setValue("X", "KZAZU");// 订单组合
						ip_header.setValue((String) ht.get("area_code"),
								"COUNTRY");// 国家代码
						ip_header.setValue((String) ht.get("akont"), "AKONT");// 总帐中的统驭科目
						// ip_header.setValue("000001", "BZIRK");//销售地区
						ip_header.setValue((String) ht.get("sap_zone_code"),
								"VKBUR");// 销售办事处
						ip_header.setValue((String) ht.get("sap_org_code"),
								"VKGRP");// 销售组
						ip_header.setValue("", "KDGRP");// 客户组
						ip_header.setValue((String) ht.get("currency_code"),
								"WAERS");// 货币currency_codecurrency_code
						ip_header.setValue("100", "AWAHR");// 订单可能性
						ip_header.setValue("4", "KALKS");// 定价过程分配到该客户
						ip_header.setValue("1", "VERSG");// 统计组
						ip_header.setValue("ZB", "VSBED");// 装运条件
						ip_header.setValue("", "AUTLF");// 为每个销售订单定义一次性交货
						ip_header.setValue("", "KZTLF");// 项目水平上的部分交货
						ip_header.setValue((String) ht.get("taxkd"), "TAXKD");// 客户税分类
																				// 国内
																				// 1
																				// 国外0
						ip_header.setValue("01", "LPRIO");// 交货优先权
						ip_header.setValue("9", "ANTLF");
						ip_header.setValue(dictname, "KLABC");

						// ip_header.setValue("CIF", "INCO1");//国际贸易条款 (部分1)
						ip_header.setValue((String) ht.get("ktgrd"), "KTGRD");// 帐户分配组
																				// 国内
																				// 01
																				// 国外
																				// 02
						ip_header.setValue(pay_condition, "ZTERM");// 收付条件代码
						// ip_header.setValue("01", "KONDA");//
						ip_header.setValue((String) ht.get("vwerk"), "VWERK");// 交货工厂公司代码1500传公司代码1130;1130传1100（家用）1120(商用)

						JCO.ParameterList input = function
								.getImportParameterList();
						if (up_in == 2) {
							input.setValue("U", "IV_FLAG");// I为新增，U为修改
						} else if (up_in == 1) {
							input.setValue("I", "IV_FLAG");// I为新增，U为修改
						}

						if (mConnection == null) {
							System.out.println("mConnection 为空");
						}

						mConnection.execute(function);
						JCO.ParameterList output = function
								.getExportParameterList();

						JCO.Table ET_MESSAGE = function.getTableParameterList()
								.getTable("ET_MESSAGE");
						String Msg = "";
						ev_subrc = output.getString("EV_SUBRC");
						if (output.getString("EV_SUBRC").equals("0")) {

							output.getValue("EV_KUNNR");
							output.getValue("EV_MSG");
							System.out.println(output.getValue("EV_KUNNR"));

							sql = " update customer set sap_code='"
									+ output.getValue("EV_KUNNR") + "'"
									+ ",sap_stat=2 " + " where cust_code='"
									+ erp_code + "'";
							this.getDataCentre().update(sql);

						} else {
							for (int m = 0; m < ET_MESSAGE.getNumRows(); m++) {
								ET_MESSAGE.setRow(m);
								Msg = Msg + ET_MESSAGE.getString("MESSAGE")
										+ ";";
							}
							throw new IllegalLogicException(Msg);
						}
					}
				}
			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}
			}
			if (ev_subrc.equals("0") && sap_code == ""
					&& sap_code.length() == 0) {
				if (custtype != 2) {
					this.putZRFC_SCM_WRITE_XD03(erp_code, 1, 2);
				}

			}
		}

	}

	// 拓展宁波
	public void putZRFC_SCM_WRITE_XD02(String erp_code) throws SinocpcException {

		String sql = "";
		if (this.db_connect(SCM_XD01) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				String name = "";
				function = createFunction(SCM_XD01);

				if (function == null) {
					System.out.println(name + "在sap中没有发现");
				} else {

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*

					sql = "select m.*,\n"
							+ "       n.zone_code sap_zone_code,\n"
							+ "       n.sap_org_code,\n"
							+ "       substr(m.cust_name, 1, 12) SORT1,\n"
							+ "       '0000' || sap_code sapcode,\n"
							+ "       case\n"
							+ "         when substr(m.cust_code, 1, 1) = 'W' then\n"
							+ "          '1122010020'\n"
							+ "         else\n"
							+ "          '1122010020'\n"
							+ "       end AKONT,\n"
							+ "       case\n"
							+ "         when substr(m.cust_code, 1, 1) = 'W' then\n"
							+ "          '02'\n"
							+ "         else\n"
							+ "          '02'\n"
							+ "       end KTGRD,\n"
							+ "       case\n"
							+ "         when substr(m.cust_code, 1, 1) = 'W' then\n"
							+ "          '0'\n" + "         else\n"
							+ "          '1'\n" + "       end taxkd,\n"
							+ "       case\n"
							+ "         when zhu_zi = 1 then\n"
							+ "          '1100'\n" + "         else\n"
							+ "          '1120'\n" + "       end VWERK,\n"
							+ "       case\n"
							+ "         when zhu_zi = 1 then\n"
							+ "          '1130'\n" + "         else\n"
							+ "          '1131'\n" + "       end vkorg,\n"
							+ "       '1130' BUKRS\n"
							+ "  from customer m, base_contract n\n"
							+ " where m.bumen = n.org_name\n"
							+ "   and cust_code = '" + erp_code + "'";

					Vector vc = this.getDataCentre().multiRowSelect(sql);
					JCO.Structure ip_header = function.getImportParameterList()
							.getStructure("IS_CUSTOMER"); // 获取import抬头结构
					if (vc.size() > 0) {
						for (int i = 0; i < vc.size(); i++) {
							Hashtable ht = (Hashtable) vc.elementAt(i);

							sql = " select distinct p.pay_condition from customer_payment_type m,payment_type p where "
									+ " p.payment_type_id=m.payment_type_id "
									+ " and cust_code='"
									+ erp_code
									+ "'"
									+ " and rownum=1 "
									+ " order by p.pay_condition ";
							String pay_condition = this.getDataCentre()
									.strSelect(sql);

							sql = " select dictname from cpcdict "
									+ " where dictcode like '%Cust_Level%'  "
									+ " and  dictvalue="
									+ Integer.parseInt((String) ht
											.get("cust_level"));
							String dictname = this.getDataCentre().strSelect(
									sql);

							if (ht != null) {
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNNR");// 购货方编号
								// ip_header.setValue((String)ht.get("vkorg"),
								// "BUKRS");//公司代码 进出口:1130 香港:1500
								ip_header.setValue((String) ht.get("bukrs"),
										"BUKRS");// 公司代码 进出口:1130 香港:1500
								ip_header.setValue((String) ht.get("vkorg"),
										"VKORG");// 销售组织 进出口:1130 香港:1500
								ip_header.setValue("00", "VTWEG");// 分销渠道
								ip_header.setValue("00", "SPART");// 部门
								// ip_header.setValue("C003", "KTOKD");//客户帐户组
								ip_header.setValue("0003", "TITLE");// 标题
								ip_header.setValue(
										(String) ht.get("cust_name"), "NAME1");// 名称
																				// 1
								ip_header.setValue((String) ht.get("sort1"),
										"SORT1");// 搜索项目 1
								ip_header.setValue("", "STREET1");// 街道名
								ip_header.setValue("ZH", "SPRAS");// 语言
								ip_header.setValue("010", "CITY1");// 城市
								ip_header.setValue("X", "KZAZU");// 订单组合
								ip_header
										.setValue((String) ht.get("area_code"),
												"COUNTRY");// 国家代码
								ip_header.setValue((String) ht.get("akont"),
										"AKONT");// 总帐中的统驭科目
								// ip_header.setValue("000001", "BZIRK");//销售地区
								ip_header.setValue((String) ht
										.get("sap_zone_code"), "VKBUR");// 销售办事处
								ip_header.setValue((String) ht
										.get("sap_org_code"), "VKGRP");// 销售组
								ip_header.setValue("", "KDGRP");// 客户组
								ip_header.setValue((String) ht
										.get("currency_code"), "WAERS");// 货币currency_codecurrency_code
								ip_header.setValue("100", "AWAHR");// 订单可能性
								ip_header.setValue("4", "KALKS");// 定价过程分配到该客户
								ip_header.setValue("1", "VERSG");// 统计组
								ip_header.setValue("ZB", "VSBED");// 装运条件
								ip_header.setValue("", "AUTLF");// 为每个销售订单定义一次性交货
								ip_header.setValue("", "KZTLF");// 项目水平上的部分交货
								ip_header.setValue((String) ht.get("taxkd"),
										"TAXKD");// 客户税分类 国内 1 国外0
								ip_header.setValue("01", "LPRIO");// 交货优先权
								ip_header.setValue("9", "ANTLF");
								ip_header.setValue(dictname, "KLABC");

								// ip_header.setValue("CIF", "INCO1");//国际贸易条款
								// (部分1)
								ip_header.setValue((String) ht.get("ktgrd"),
										"KTGRD");// 帐户分配组 国内 01 国外 02
								ip_header.setValue(pay_condition, "ZTERM");// 收付条件代码
								// ip_header.setValue("01", "KONDA");//
								ip_header.setValue((String) ht.get("vwerk"),
										"VWERK");// 交货工厂公司代码1500传公司代码1130;1130传1100（家用）1120(商用)

								ip_header.setValue((String) ht.get("sapcode"),
										"KUNRG");
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNWE");
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNRE");
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNAG");

								JCO.ParameterList input = function
										.getImportParameterList();

								input.setValue("M", "IV_FLAG");// I为新增，U为修改，
																// M为转组织

								if (mConnection == null) {
									System.out.println("mConnection 为空");
								}

								mConnection.execute(function);
								JCO.ParameterList output = function
										.getExportParameterList();

								JCO.Table ET_MESSAGE = function
										.getTableParameterList().getTable(
												"ET_MESSAGE");
								String Msg = "";
								if (output.getString("EV_SUBRC").equals("0")) {

									sql = " update customer set is_tz=2 "
											+ " where cust_code='" + erp_code
											+ "'";
									this.getDataCentre().update(sql);

								} else {
									for (int m = 0; m < ET_MESSAGE.getNumRows(); m++) {
										ET_MESSAGE.setRow(m);
										Msg = Msg
												+ ET_MESSAGE
														.getString("MESSAGE")
												+ ";";
									}
									throw new IllegalLogicException(Msg);
								}
							}
						}
					}
				}
			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}
			}
		}
	}

	// 拓展香港
	public void putZRFC_SCM_WRITE_XD04(String erp_code) throws SinocpcException {

		String sql = "";
		if (this.db_connect(SCM_XD01) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				String name = "";
				function = createFunction(SCM_XD01);

				if (function == null) {
					System.out.println(name + "在sap中没有发现");
				} else {

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*

					sql = "select m.*,\n"
							+ "       n.zone_code sap_zone_code,\n"
							+ "       n.sap_org_code,\n"
							+ "       substr(m.cust_name, 1, 12) SORT1,\n"
							+ "       '0000' || sap_code sapcode,\n"
							+ "       case\n"
							+ "         when substr(m.cust_code, 1, 1) = 'W' then\n"
							+ "          '1122010020'\n"
							+ "         else\n"
							+ "          '1122010020'\n"
							+ "       end AKONT,\n"
							+ "       case\n"
							+ "         when substr(m.cust_code, 1, 1) = 'W' then\n"
							+ "          '02'\n"
							+ "         else\n"
							+ "          '02'\n"
							+ "       end KTGRD,\n"
							+ "       case\n"
							+ "         when substr(m.cust_code, 1, 1) = 'W' then\n"
							+ "          '0'\n" + "         else\n"
							+ "          '1'\n" + "       end taxkd,\n"
							+ "       case\n"
							+ "         when zhu_zi = 1 then\n"
							+ "          '1130'\n" + "         else\n"
							+ "          '1131'\n" + "       end VWERK,\n"
							+ "       case\n"
							+ "         when zhu_zi = 1 then\n"
							+ "          '1500'\n" + "         else\n"
							+ "          '1501'\n" + "       end vkorg,\n"
							+ "       '1500' BUKRS\n"
							+ "  from customer m, base_contract n\n"
							+ " where m.bumen = n.org_name\n"
							+ "   and cust_code ='" + erp_code + "'";

					Vector vc = this.getDataCentre().multiRowSelect(sql);
					JCO.Structure ip_header = function.getImportParameterList()
							.getStructure("IS_CUSTOMER"); // 获取import抬头结构
					if (vc.size() > 0) {
						for (int i = 0; i < vc.size(); i++) {
							Hashtable ht = (Hashtable) vc.elementAt(i);

							sql = " select distinct p.pay_condition from customer_payment_type m,payment_type p where "
									+ " p.payment_type_id=m.payment_type_id "
									+ " and cust_code='"
									+ erp_code
									+ "'"
									+ " and rownum=1 "
									+ " order by p.pay_condition ";
							String pay_condition = this.getDataCentre()
									.strSelect(sql);

							sql = " select dictname from cpcdict "
									+ " where dictcode like '%Cust_Level%'  "
									+ " and  dictvalue="
									+ Integer.parseInt((String) ht
											.get("cust_level"));
							String dictname = this.getDataCentre().strSelect(
									sql);

							if (ht != null) {
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNNR");// 购货方编号
								// ip_header.setValue((String)ht.get("vkorg"),
								// "BUKRS");//公司代码 进出口:1130 香港:1500
								ip_header.setValue("1500", "BUKRS");// 公司代码
																	// 进出口:1130
																	// 香港:1500
								ip_header.setValue((String) ht.get("vkorg"),
										"VKORG");// 销售组织 进出口:1130 香港:1500
								ip_header.setValue("00", "VTWEG");// 分销渠道
								ip_header.setValue("00", "SPART");// 部门
								// ip_header.setValue("C003", "KTOKD");//客户帐户组
								ip_header.setValue("0003", "TITLE");// 标题
								ip_header.setValue(
										(String) ht.get("cust_name"), "NAME1");// 名称
																				// 1
								ip_header.setValue((String) ht.get("sort1"),
										"SORT1");// 搜索项目 1
								ip_header.setValue("", "STREET1");// 街道名
								ip_header.setValue("ZH", "SPRAS");// 语言
								ip_header.setValue("010", "CITY1");// 城市
								ip_header.setValue("X", "KZAZU");// 订单组合
								ip_header
										.setValue((String) ht.get("area_code"),
												"COUNTRY");// 国家代码
								ip_header.setValue((String) ht.get("akont"),
										"AKONT");// 总帐中的统驭科目
								// ip_header.setValue("000001", "BZIRK");//销售地区
								ip_header.setValue((String) ht
										.get("sap_zone_code"), "VKBUR");// 销售办事处
								ip_header.setValue((String) ht
										.get("sap_org_code"), "VKGRP");// 销售组
								ip_header.setValue("", "KDGRP");// 客户组
								ip_header.setValue((String) ht
										.get("currency_code"), "WAERS");// 货币currency_codecurrency_code
								ip_header.setValue("100", "AWAHR");// 订单可能性
								ip_header.setValue("4", "KALKS");// 定价过程分配到该客户
								ip_header.setValue("1", "VERSG");// 统计组
								ip_header.setValue("ZB", "VSBED");// 装运条件
								ip_header.setValue("", "AUTLF");// 为每个销售订单定义一次性交货
								ip_header.setValue("", "KZTLF");// 项目水平上的部分交货
								ip_header.setValue((String) ht.get("taxkd"),
										"TAXKD");// 客户税分类 国内 1 国外0
								ip_header.setValue("01", "LPRIO");// 交货优先权
								ip_header.setValue("9", "ANTLF");
								ip_header.setValue(dictname, "KLABC");

								// ip_header.setValue("CIF", "INCO1");//国际贸易条款
								// (部分1)
								ip_header.setValue((String) ht.get("ktgrd"),
										"KTGRD");// 帐户分配组 国内 01 国外 02
								ip_header.setValue(pay_condition, "ZTERM");// 收付条件代码
								// ip_header.setValue("01", "KONDA");//
								ip_header.setValue((String) ht.get("vwerk"),
										"VWERK");// 交货工厂公司代码1500传公司代码1130;1130传1100（家用）1120(商用)

								ip_header.setValue((String) ht.get("sapcode"),
										"KUNRG");
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNWE");
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNRE");
								ip_header.setValue((String) ht.get("sapcode"),
										"KUNAG");

								JCO.ParameterList input = function
										.getImportParameterList();

								input.setValue("M", "IV_FLAG");// I为新增，U为修改，
																// M为转组织

								if (mConnection == null) {
									System.out.println("mConnection 为空");
								}

								mConnection.execute(function);
								JCO.ParameterList output = function
										.getExportParameterList();

								JCO.Table ET_MESSAGE = function
										.getTableParameterList().getTable(
												"ET_MESSAGE");
								String Msg = "";
								if (output.getString("EV_SUBRC").equals("0")) {

									sql = " update customer set is_tz=2 "
											+ " where cust_code='" + erp_code
											+ "'";
									this.getDataCentre().update(sql);

								} else {
									for (int m = 0; m < ET_MESSAGE.getNumRows(); m++) {
										ET_MESSAGE.setRow(m);
										Msg = Msg
												+ ET_MESSAGE
														.getString("MESSAGE")
												+ ";";
									}
									throw new IllegalLogicException(Msg);
								}
							}
						}
					}
				}
			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}
			}
		}
	}

	*//**
	 *客户写香港组织 1500
	 * *//*
	public void putZRFC_SCM_WRITE_XD03(String erp_code, int custtype, int up_in)
			throws SinocpcException {

		String sql = "";
		if (this.db_connect(SCM_XD01) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				String name = "";
				function = createFunction(SCM_XD01);

				if (function == null) {
					System.out.println(name + "在sap中没有发现");
				} else {

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*

					sql = "select m.*,n.zone_code  sap_zone_code,n.sap_org_code,substr(m.cust_name,1,12)SORT1,'0000'||sap_code sapcode, "
							+ " case when substr(m.cust_code,1,1)='W'then '1122010020'else "
							+ " '1122010020'end AKONT, "
							+ " case when substr(m.cust_code,1,1)='W'then '02'else "
							+ " '02'end KTGRD, "
							+ " case when substr(m.cust_code,1,1)='W'then '0'else "
							+ " '1'end taxkd, "
							+ " case when  c.superid<>223 then '1130' else'1131' end VWERK "
							+ " ,case when c.superid<>223 then '1500' else'1501' end vkorg "
							+ " from customer m,base_contract n,cpcorg c "
							+ " where m.org_id=n.org_id and m.org_id=c.orgid "
							+ " and cust_code='" + erp_code + "'";

					Hashtable ht = this.getDataCentre().oneRowSelect(sql);
					JCO.Structure ip_header = function.getImportParameterList()
							.getStructure("IS_CUSTOMER"); // 获取import抬头结构

					sql = " select distinct p.pay_condition from customer_payment_type m,payment_type p where "
							+ " p.payment_type_id=m.payment_type_id "
							+ " and cust_code='"
							+ erp_code
							+ "'"
							+ " and rownum=1 " + " order by p.pay_condition ";
					String pay_condition = this.getDataCentre().strSelect(sql);

					sql = " select dictname from cpcdict "
							+ " where dictcode like '%Cust_Level%'  "
							+ " and  dictvalue="
							+ Integer.parseInt((String) ht.get("cust_level"));
					String dictname = this.getDataCentre().strSelect(sql);

					if (ht != null) {
						ip_header.setValue((String) ht.get("sapcode"), "KUNNR");// 购货方编号
						// ip_header.setValue((String)ht.get("vkorg"),
						// "BUKRS");//公司代码 进出口:1130 香港:1500
						ip_header.setValue("1500", "BUKRS");// 公司代码 进出口:1130
															// 香港:1500
						ip_header.setValue((String) ht.get("vkorg"), "VKORG");// 销售组织
																				// 进出口:1130
																				// 香港:1500
						ip_header.setValue("00", "VTWEG");// 分销渠道
						ip_header.setValue("00", "SPART");// 部门
						// ip_header.setValue("C003", "KTOKD");//客户帐户组
						ip_header.setValue("0003", "TITLE");// 标题
						ip_header.setValue((String) ht.get("cust_name"),
								"NAME1");// 名称 1
						ip_header.setValue((String) ht.get("sort1"), "SORT1");// 搜索项目
																				// 1
						ip_header.setValue("", "STREET1");// 街道名
						ip_header.setValue("ZH", "SPRAS");// 语言
						ip_header.setValue("010", "CITY1");// 城市
						ip_header.setValue("X", "KZAZU");// 订单组合
						ip_header.setValue((String) ht.get("area_code"),
								"COUNTRY");// 国家代码
						ip_header.setValue((String) ht.get("akont"), "AKONT");// 总帐中的统驭科目
						// ip_header.setValue("000001", "BZIRK");//销售地区
						ip_header.setValue((String) ht.get("sap_zone_code"),
								"VKBUR");// 销售办事处
						ip_header.setValue((String) ht.get("sap_org_code"),
								"VKGRP");// 销售组
						ip_header.setValue("", "KDGRP");// 客户组
						ip_header.setValue((String) ht.get("currency_code"),
								"WAERS");// 货币currency_codecurrency_code
						ip_header.setValue("100", "AWAHR");// 订单可能性
						ip_header.setValue("4", "KALKS");// 定价过程分配到该客户
						ip_header.setValue("1", "VERSG");// 统计组
						ip_header.setValue("ZB", "VSBED");// 装运条件
						ip_header.setValue("", "AUTLF");// 为每个销售订单定义一次性交货
						ip_header.setValue("", "KZTLF");// 项目水平上的部分交货
						ip_header.setValue((String) ht.get("taxkd"), "TAXKD");// 客户税分类
																				// 国内
																				// 1
																				// 国外0
						ip_header.setValue("01", "LPRIO");// 交货优先权
						ip_header.setValue("9", "ANTLF");
						ip_header.setValue(dictname, "KLABC");

						// ip_header.setValue("CIF", "INCO1");//国际贸易条款 (部分1)
						ip_header.setValue((String) ht.get("ktgrd"), "KTGRD");// 帐户分配组
																				// 国内
																				// 01
																				// 国外
																				// 02
						ip_header.setValue(pay_condition, "ZTERM");// 收付条件代码
						// ip_header.setValue("01", "KONDA");//
						ip_header.setValue((String) ht.get("vwerk"), "VWERK");// 交货工厂公司代码1500传公司代码1130;1130传1100（家用）1120(商用)

						ip_header.setValue((String) ht.get("sapcode"), "KUNRG");
						ip_header.setValue((String) ht.get("sapcode"), "KUNWE");
						ip_header.setValue((String) ht.get("sapcode"), "KUNRE");
						ip_header.setValue((String) ht.get("sapcode"), "KUNAG");

						JCO.ParameterList input = function
								.getImportParameterList();

						input.setValue("M", "IV_FLAG");// I为新增，U为修改， M为转组织

						if (mConnection == null) {
							System.out.println("mConnection 为空");
						}

						mConnection.execute(function);
						JCO.ParameterList output = function
								.getExportParameterList();

						JCO.Table ET_MESSAGE = function.getTableParameterList()
								.getTable("ET_MESSAGE");
						String Msg = "";
						if (output.getString("EV_SUBRC").equals("0")) {

							// output.getValue("EV_KUNNR");
							// output.getValue("EV_MSG");
							// System.out.println(output.getValue("EV_KUNNR"));

							sql = " update customer set sap_code='"
									+ output.getValue("EV_KUNNR") + "'"
									+ ",sap_stat=2 " + " where cust_code='"
									+ erp_code + "'";
							this.getDataCentre().update(sql);

						} else {
							for (int m = 0; m < ET_MESSAGE.getNumRows(); m++) {
								ET_MESSAGE.setRow(m);
								Msg = Msg + ET_MESSAGE.getString("MESSAGE")
										+ ";";
							}
							throw new IllegalLogicException(Msg);
						}
					}
				}
			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}
			}
		}
	}

	*//**
	 * 读1570库存函数“ZRFC_MM_READ_MB52”出库单审核最后一步判断库存
	 * *//*
	public void getItemInventory1(String ip_matnr, String iv_vbeln)
			throws SinocpcException {

		if (this.db_connect(SCM_MB52) == 2) {
			JCO.Function function = null;
			JCO.Table ztmtrack = null;

			try {
				getConnection();
				function = createFunction(SCM_MB52); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_MB52 + "在sap中没有发现");
				} else {
					*//**
					 *输入要读取物料号码
					 * *//*
					JCO.ParameterList input = function.getImportParameterList();
					input.setValue(ip_matnr, "IV_MATNR");// IP_MATNR
															// IV_MATNR物料号码
					input.setValue(iv_vbeln, "IV_VBELN");// I销售单号

					JCO.ParameterList list = function.getTableParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
					*//**
					 * 输入指定的工厂地点
					 * 
					 * *//*
					JCO.Table it_werks = list.getTable("IT_WERKS");
					it_werks.appendRow();
					it_werks.setRow(0);
					it_werks.setValue("I", "SIGN");
					it_werks.setValue("EQ", "OPTION");
					it_werks.setValue("1100", "LOW");
					it_werks.setValue("", "HIGH");

					*//**
					 * 输入指定的库存地点
					 * *//*
					JCO.Table it_lgort = list.getTable("IT_LGORT");
					it_lgort.appendRow();
					it_lgort.setRow(0);
					it_lgort.setValue("I", "SIGN");
					it_lgort.setValue("EQ", "OPTION");
					it_lgort.setValue("1101", "LOW");
					it_lgort.setValue("", "HIGH");// 11103015000009

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}
					mConnection.execute(function);

					ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。

					System.out.println("ztmtrack.getNumRows() ="
							+ ztmtrack.getNumRows());

					JCO.ParameterList output = function
							.getExportParameterList();

					String Msg = "";

					JCO.Table ET_MESSAGE = function.getTableParameterList()
							.getTable("ET_MESSAGE");

					JCO.Table ET_OUTPUT = function.getTableParameterList()
							.getTable("ET_OUTPUT");

					System.out.println(output.getValue("EV_SUBRC"));
					if (output.getString("EV_SUBRC").equals("0")) {
						for (int i = 0; i < ztmtrack.getNumRows(); i++) {
							ztmtrack.setRow(i);// 指定行

							double erpqty;
							String labst = ztmtrack.getString("LABST");
							erpqty = new Double(labst).doubleValue();
							System.out.println(labst);

							// if(erpqty<qty){
							// throw new
							// IllegalLogicException("该物料号<"+ip_matnr+">在SAP系统1570库位的库存数量不足！");
							// }

							// System.out.println(erpqty);

						}

					} else {
						for (int m = 0; m < ET_MESSAGE.getNumRows(); m++) {
							ET_MESSAGE.setRow(m);
							Msg = Msg + ET_MESSAGE.getString("MESSAGE") + ";";
						}
						System.out.println("222:" + Msg);
					}

				}
			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}
			}
		}

	}

	public void getItemInventory1(String name, String ip_matnr, int qty)
			throws SinocpcException {

		JCO.Function function = null;
		JCO.Table ztmtrack = null;

		getConnection();
		function = createFunction(name); // 取物料数据表
		if (function == null) {
			System.out.println(name + "在sap中没有发现");
		} else {
			*//**
			 *输入要读取物料号码
			 * *//*
			JCO.ParameterList input = function.getImportParameterList();
			input.setValue(ip_matnr, "IP_MATNR");

			JCO.ParameterList list = function.getTableParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
			*//**
			 * 输入指定的工厂地点
			 * *//*
			JCO.Table it_werks = list.getTable("IT_WERKS");
			it_werks.appendRow();
			it_werks.setRow(0);
			it_werks.setValue("I", "SIGN");
			it_werks.setValue("EQ", "OPTION");
			it_werks.setValue("1130", "LOW");
			// it_werks.setValue("11103015000009", "HIGH");

			*//**
			 * 输入指定的库存地点
			 * *//*
			JCO.Table it_lgort = list.getTable("IT_LGORT");
			it_lgort.appendRow();
			it_lgort.setRow(0);
			it_lgort.setValue("I", "SIGN");
			it_lgort.setValue("EQ", "OPTION");
			it_lgort.setValue("1391", "LOW");
			it_lgort.setValue(ip_matnr, "HIGH");// 11103015000009

			if (mConnection == null) {
				System.out.println("mConnection 为空");
			}
			mConnection.execute(function);
			Hashtable ht = null;

			ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。
			System.out.println("ztmtrack.getNumRows() = "
					+ ztmtrack.getNumRows());
			for (int i = 0; i < ztmtrack.getNumRows(); i++) {
				ztmtrack.setRow(i);// 指定行

				double erpqty;
				String labst = ztmtrack.getString("LABST");
				erpqty = new Double(labst).doubleValue();

				// if(erpqty<qty){
				// throw new
				// IllegalLogicException("该物料号<"+ip_matnr+">在SAP系统1570库位的库存数量<"+erpqty+">小于本次出库数量<"+qty+">,不能审核出库！");
				// }
				// ht = new Hashtable();

				System.out.println(" 物料号码：" + ztmtrack.getString("MATNR")
						+ "\n" + " 物料描述：" + ztmtrack.getString("MAKTX") + "\n"
						+ " 工厂：" + ztmtrack.getString("WERKS") + "\n"
						+ " 库存地点：" + ztmtrack.getString("LGORT") + "\n"
						+ " 仓储地点的描述：" + ztmtrack.getString("LGOBE") + "\n"
						+ " 非限制使用的估价的库存：" + ztmtrack.getString("LABST") + "\n"
						+ " 在运库存 (从一库存地到另一库存地)：" + ztmtrack.getString("UMLME"));
				// slist.add(ht);

			}

			JCO.Table ET_OUTPUT = function.getTableParameterList().getTable(
					"ET_OUTPUT");

			String Msg = "";
			for (int m = 0; m < ET_OUTPUT.getNumRows(); m++) {
				ET_OUTPUT.setRow(m);
				Msg = Msg + ET_OUTPUT.getString("LABST") + ";";
			}
			System.out.println("111:" + Msg);

			if (mConnection != null) {
				mConnection.disconnect();
			}
		}
	}

	*//**
	 * 读1520 1570 出入库凭证 140520120208
	 * 
	 * @throws SinocpcException
	 * *//*
	public void getZRFC_SCM_READ_MB51() throws SinocpcException {

		if (this.db_connect(SCM_MB51) == 2) {

			String sql = "";
			JCO.Function function = null;
			JCO.Table ztmtrack = null;

			getConnection();
			function = createFunction(SCM_MB51); // 取物料数据表
			if (function == null) {
				System.out.println(SCM_MB51 + "在sap中没有发现");
			} else {

				JCO.ParameterList list = function.getTableParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值

				*//**
				 * 输入指定的工厂地点
				 * *//*
				JCO.Table it_werks = list.getTable("IT_WERKS");
				it_werks.appendRow();
				it_werks.setRow(0);
				it_werks.setValue("I", "SIGN");
				it_werks.setValue("EQ", "OPTION");
				it_werks.setValue("1100", "LOW");
				it_werks.setValue("", "HIGH");

				*//**
				 * 输入指定的库存地点
				 * *//*
				JCO.Table it_lgort = list.getTable("IT_LGORT");

				it_lgort.appendRow();
				it_lgort.setRow(0);
				it_lgort.setValue("I", "SIGN");
				it_lgort.setValue("EQ", "OPTION");
				it_lgort.setValue("1101", "LOW");
				it_lgort.setValue("", "HIGH");// 11103015000009

				*//**
				 * 移动类型输入表
				 * *//*
				JCO.Table it_bwart = list.getTable("IT_BWART");
				it_bwart.appendRow();
				it_bwart.setRow(0);
				it_bwart.setValue("I", "SIGN");
				it_bwart.setValue("EQ", "OPTION");
				it_bwart.setValue("601", "LOW");
				it_bwart.setValue("", "HIGH");

				*//**
				 * 记帐日期输入表
				 * *//*
				// JCO.Table it_budat = list.getTable("IT_BUDAT");
				// it_budat.appendRow();
				// it_budat.setRow(0);
				// it_budat.setValue("I", "SIGN");
				// it_budat.setValue("EQ", "OPTION");
				// it_budat.setValue("", "LOW");
				// it_budat.setValue("", "HIGH");

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}
				mConnection.execute(function);

				ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。

				System.out.println("ztmtrack.getNumRows() = "
						+ ztmtrack.getNumRows());
				for (int i = 0; i < ztmtrack.getNumRows(); i++) {
					ztmtrack.setRow(i);// 指定行
					String menge = "";
					String matnr = "";
					matnr = ztmtrack.getString("MATNR").trim();
					if (matnr.length() > 0
							&& matnr.substring(0, 5).equals("4F739")) {

						// 判断出入库类型 S 代表入库 H 代表出库
						if (ztmtrack.getString("SHKZG").equals("S")) {
							menge = ztmtrack.getString("MENGE");
						} else {
							menge = "-" + ztmtrack.getString("MENGE");
						}

						// if(ztmtrack.getString("LGORT").equals("1520") &&
						// ztmtrack.getString("BWART").equals("101")){
						//								    	  
						// sql="update sale_prod_line set already_in_qty=nvl(already_in_qty,0)+"+menge
						// +" ,already_in_time=to_date('"+ztmtrack.getString("BUDAT")+"','yyyy-mm-dd')"
						// +" where erp_code='"+matnr+"'";
						// this.getDataCentre().update(sql);
						// }

						// System.out.println(" 物料凭证编号：" +
						// ztmtrack.getString("MBLNR")+"\n"
						// + " 物料凭证的年份：" + ztmtrack.getString("MJAHR")+"\n"
						// + " 物料凭证中的项目："+ ztmtrack.getString("ZEILE")+"\n"
						// + " 凭证记帐日期："+ ztmtrack.getString("BUDAT")+"\n"
						// + " 物料号码："+ ztmtrack.getString("MATNR")+"\n"
						// + " 物料描述："+ ztmtrack.getString("MAKTX")+"\n"
						// + " 库存地点："+ ztmtrack.getString("LGORT")+"\n"
						// + " 仓储地点的描述："+ ztmtrack.getString("LGOBE1")+"\n"
						// + " 收货/发货库存地点："+ ztmtrack.getString("UMLGO")+"\n"
						// + " 仓储地点的描述："+ ztmtrack.getString("LGOBE2")+"\n"
						// + " 移动类型(库存管理)："+ ztmtrack.getString("BWART")+"\n"
						// + " 数量："+ ztmtrack.getString("MENGE")+"\n"
						// + " 基本计量单位："+ ztmtrack.getString("MEINS")+"\n"
						// + " 工厂："+ ztmtrack.getString("WERKS")+"\n"
						// + " 转换的单位："+ ztmtrack.getString("MEINS_C"));
						//											

					}
				}
			}

			if (mConnection != null) {
				mConnection.disconnect();
			}
		}
	}

	*//**
	 *创建销售订单交货单 VL01N
	 * *//*

	public void ZIF_OMS_DELIVERY_CREATE_VL01N(Hashtable ht, Vector vc,
			String iv_vbeln) throws SinocpcException {
		String sql = "";
		if (this.db_connect(SCM_VL01N) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_VL01N); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_VL01N + "在sap中没有发现");
				}

				*//**
				 * VL01N创建外向交货订单及发货过帐输入
				 * *//*

				JCO.ParameterList input = function.getImportParameterList();
				input.setValue((String) ht.get("check_time"), "IV_WADAT");// 实际货物移动日期
				input.setValue("9999-12-31", "IV_LEDAT");// 交货创建日期

				// 交货行项目
				JCO.ParameterList list = function.getTableParameterList();
				JCO.Table it_item = list.getTable("IT_ITEMS"); // 是一个内表。

				for (int i = 0; i < vc.size(); i++) {
					it_item.appendRow();
					it_item.setRow(i + 1);
					Hashtable htline = (Hashtable) vc.elementAt(i);
					it_item
							.setValue((String) htline.get("iv_vbeln"),
									"REF_DOC");// 参考凭证销售单号
					it_item.setValue((String) htline.get("seq"), "REF_ITEM");// 参考行项目
					it_item.setValue((String) htline.get("out_qty"), "DLV_QTY");// 实际已交货量（按销售单位）
					it_item.setValue("PC", "SALES_UNIT");// 单位 "PC"
				}

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);

				// 返回参数
				JCO.Table ET_LOG = function.getTableParameterList().getTable(
						"ET_MESSAGE");

				// 导出参数
				JCO.ParameterList output = function.getExportParameterList();
				String msg = "";

				if (output.getString("EV_SUBRC").equals("0")) {
					// SD凭证 ： 交货： 项目数据
					sql = "select nvl(max(seq),0)+1 from sale_ship_notice_sap_line where notice_id="
							+ (String) ht.get("notice_id");
					int lineseq = this.getDataCentre().intSelect(sql);

					JCO.Table et_lips = function.getTableParameterList()
							.getTable("ET_LIPS");
					for (int i = 0; i < et_lips.getNumRows(); i++) {
						et_lips.setRow(i);// 指定行 LFIMG LGMNG
						String posnr = et_lips.getString("POSNR");// 行项目
						String lfimg = et_lips.getString("LFIMG");// 发货数量
						int notice_id = Integer.parseInt((String) ht
								.get("notice_id"));
						String erp_code = et_lips.getString("MATNR");
						String ab_votes = "";
						sql = " select c.ab_votes from sale_ship_item_line3 c,sale_notice_sap b "
								+ " where c.notice_id="
								+ notice_id
								+ " and c.erp_code='"
								+ erp_code
								+ "'"
								+ " and c.out_qty="
								+ lfimg
								+ " and c.notice_id=b.notice_id "
								+ " and c.erp_code=b.erp_code  "
								+ " and c.ab_votes not in(select ab_votes from sale_notice_sap where notice_id="
								+ notice_id
								+ " and erp_code='"
								+ erp_code
								+ "'" + " ) " + " and rownum=1 ";
						String ab_votes1 = this.getDataCentre().strSelect(sql);

						sql = "select c.ab_votes from sale_ship_item_line3 c "
								+ " where c.notice_id=" + notice_id
								+ " and c.erp_code='" + erp_code + "'"
								+ " and c.out_qty=" + lfimg + " and rownum=1 "
								+ " order by c.ab_votes";
						String ab_votes2 = this.getDataCentre().strSelect(sql);

						if (ab_votes1 != null && ab_votes1 != "") {
							ab_votes = ab_votes1;
						} else {
							ab_votes = ab_votes2;
						}

						String seq = posnr.trim();
						sql = "select * from sale_ship_item_line3 where notice_id="
								+ (String) ht.get("notice_id")
								+ " and erp_code='"
								+ et_lips.getString("MATNR")
								+ "'"
								+ " and ab_votes='" + ab_votes + "'";
						Hashtable htline3 = this.getDataCentre().oneRowSelect(
								sql);
						int out_qty = 0;
						int prod_line_id = 0;
						if (htline3 != null) {
							out_qty = Integer.parseInt((String) htline3
									.get("out_qty"));
							prod_line_id = Integer.parseInt((String) htline3
									.get("prod_line_id"));
						}
						sql = " insert into sale_notice_sap("
								+ " NOTICE_NO,"
								+ " NOTICE_ID,"
								+ " ERP_CODE,"
								+ " IV_VBELN,"
								+ " SEQ,ab_votes,out_qty,prod_line_id,lineseq)values('"
								+ (String) ht.get("notice_no") + "',"
								+ (String) ht.get("notice_id") + ",'"
								+ et_lips.getString("MATNR") + "','"
								+ output.getString("EV_VBELN") + "','" + seq
								+ "','" + ab_votes + "'," + out_qty + ","
								+ prod_line_id + "," + lineseq + ")";
						this.getDataCentre().execute(sql);

					}

					sql = "insert into sale_ship_notice_sap_line(pi_id,pi_no,notice_id,notice_no,interior_sap,sale_sap,delorder_sap,seq) values("
							+ (String) ht.get("pi_id")
							+ ",'"
							+ (String) ht.get("pi_no")
							+ "',"
							+ (String) ht.get("notice_id")
							+ ",'"
							+ (String) ht.get("notice_no")
							+ "','"
							+ iv_vbeln
							+ "','"
							+ iv_vbeln
							+ "','"
							+ output.getString("EV_VBELN")
							+ "',"
							+ lineseq
							+ ")";
					this.getDataCentre().execute(sql);

					sql = " update sale_ship_notice_header set sap_total_amt=nvl(total_amt,0) "
							+ " where notice_id="
							+ (String) ht.get("notice_id");
					this.getDataCentre().update(sql);

				} else {
					for (int m = 0; m < ET_LOG.getNumRows(); m++) {
						ET_LOG.setRow(m);
						msg = msg + ET_LOG.getString("MESSAGE") + ";";
					}

					sql = "insert into sale_omssap_return_log ( "
							+ " pi_id,pi_no,notice_id ,notice_no,note,create_time,create_name  )"
							+ " values(" + (String) ht.get("pi_id") + ",'"
							+ (String) ht.get("pi_no") + "',"
							+ (String) ht.get("notice_id") + ",'"
							+ (String) ht.get("notice_no") + "','" + msg
							+ "',sysdate,'" + this.getUserBean().UserId + "')";
					this.getDataCentre().execute(sql);

					// throw new IllegalLogicException(msg);

				}

			} catch (Exception ex) {
				// this.getDataCentre().commit();
				ex.printStackTrace();
				// throw new IllegalLogicException(ex.toString());
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}

		}
	}

	*//**
	 * 功能：字符串转换成整型 add by chenli
	 * 
	 * @param str
	 * @param Def
	 * @return
	 * @throws java.lang.NumberFormatException
	 *//*
	public BigDecimal StrToBigDecimalDef(String str, BigDecimal Def)
			throws java.lang.NumberFormatException {
		BigDecimal Numb;
		try {
			Numb = new BigDecimal(str);
		} catch (Exception e) {
			return Def;
		}
		return Numb;
	}

	*//**
	 *创建销售订单开票VF01
	 * *//*
	public void ZIF_OMS_WRITE_VF01(Vector vc, int notice_id, String vbeln,
			String gl_date) throws SinocpcException {

		String sql = "";
		if (this.db_connect(SCM_VF01) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_VF01); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_VF01 + "在sap中没有发现");
				}

				*//**
				 * VL01N创建外向交货订单及发货过帐输入
				 * *//*
				JCO.ParameterList input = function.getImportParameterList();
				input.setValue("", "IV_FLAG");// 如果是借项凭证输入"x"

				// 开票交货单号getTableParameterList
				JCO.ParameterList list = function.getTableParameterList();

				JCO.Table it_vbeln = list.getTable("IT_VBELN"); // 是一个内表。
				it_vbeln.appendRow();
				it_vbeln.setRow(1);
				it_vbeln.setValue(vbeln, "VBELN");// 交货单号

				// 开票行项目修改价格

				JCO.Table it_condition = list.getTable("IT_CONDITION"); // 是一个内表。
				if (vc.size() > 0) {
					for (int i = 0; i < vc.size(); i++) {
						Hashtable htvc = (Hashtable) vc.elementAt(i);
						it_condition.appendRow();
						it_condition.setRow(i + 1);

						it_condition.setValue(vbeln, "VBELN");// 交货单号
						it_condition
								.setValue((String) htvc.get("seq"), "POSNR");// 交货行项目
						it_condition.setValue((String) htvc.get("kschl"),
								"KSCHL");// 条件类型//ZPRS 退税率价格类型
						it_condition.setValue((String) htvc.get("price"),
								"KBETR");// 单价
						it_condition.setValue((String) htvc.get("out_qty"),
								"KPEIN");// 条件定价单位
						// it_condition.setValue("1","KPEIN");//条件定价单位
					}
				}

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);

				JCO.Table ET_LOG = function.getTableParameterList().getTable(
						"ET_MESSAGE");

				JCO.ParameterList output = function.getExportParameterList();

				String msg = "";

				// 判断是否成功写日志
				// System.out.println(output.getString("EV_SUBRC"));
				// System.out.println(output.getString("EV_MSG"));

				if (output.getString("EV_SUBRC").equals("0")) {

					// System.out.println(output.getString("EV_VBELN"));
					// System.out.println(output.getString("EV_BELNR"));
					// String
					// kaipiao_sap=output.getString("EV_VBELN")+";"+output.getString("EV_BELNR");
					sql = "update sale_ship_notice_sap_line set kaipiao_sap='"
							+ output.getString("EV_BELNR") + "'"
							+ ",fapiao_sap='" + output.getString("EV_VBELN")
							+ "'" + " where notice_id=" + notice_id
							+ " and delorder_sap='" + vbeln + "'";
					this.getDataCentre().update(sql);

					sql = "update sale_ship_notice_header set is_kaip=2"
							+ " where notice_id=" + notice_id;
					this.getDataCentre().update(sql);

					sql = " update Bill_Invoice_Header set Is_Erp_Process=2 "
							+ ",ERP_TIME=to_date('" + gl_date
							+ "','yyyy-mm-dd')" + " where notice_id="
							+ notice_id;
					this.getDataCentre().update(sql);

				} else {
					for (int m = 0; m < ET_LOG.getNumRows(); m++) {
						ET_LOG.setRow(m);
						msg = msg + ET_LOG.getString("MESSAGE") + ";";
					}
					throw new IllegalLogicException(msg);
				}

			} catch (Exception ex) {
				this.getDataCentre().commit();
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}

	}

	*//**
	 *创建销售订单开票VF01
	 * *//*
	public void ZIF_OMS_WRITE_VF011() throws SinocpcException {

		String sql = "";
		JCO.Function function = null;
		try {
			getConnection();
			function = createFunction(SCM_VF01); // 取物料数据表
			if (function == null) {
				System.out.println(SCM_VF01 + "在sap中没有发现");
			}

			*//**
			 * VL01N创建外向交货订单及发货过帐输入
			 * *//*
			JCO.ParameterList input = function.getImportParameterList();
			input.setValue("", "IV_FLAG");// 如果是借项凭证输入"x"

			// 开票交货单号getTableParameterList
			JCO.ParameterList list = function.getTableParameterList();

			JCO.Table it_vbeln = list.getTable("IT_VBELN"); // 是一个内表。
			it_vbeln.appendRow();
			it_vbeln.setRow(1);
			it_vbeln.setValue("0080000159", "VBELN");// 交货单号

			// 开票行项目修改价格

			JCO.Table it_condition = list.getTable("IT_CONDITION"); // 是一个内表。
			it_condition.appendRow();
			it_condition.setRow(1);

			it_condition.setValue("0080000159", "VBELN");// 交货单号
			it_condition.setValue("1000", "POSNR");// 交货行项目
			it_condition.setValue("ZBX0", "KSCHL");// 条件类型
			it_condition.setValue("20", "KBETR");// 单价
			it_condition.setValue("1", "KPEIN");// 条件定价单位

			it_condition.appendRow();
			it_condition.setRow(2);

			it_condition.setValue("0080000159", "VBELN");// 交货单号
			it_condition.setValue("1000", "POSNR");// 交货行项目
			it_condition.setValue("ZKF1", "KSCHL");// 条件类型
			it_condition.setValue("30", "KBETR");// 单价
			it_condition.setValue("1", "KPEIN");// 条件定价单位

			it_condition.appendRow();
			it_condition.setRow(3);

			it_condition.setValue("0080000159", "VBELN");// 交货单号
			it_condition.setValue("1000", "POSNR");// 交货行项目
			it_condition.setValue("ZPR1", "KSCHL");// 条件类型
			it_condition.setValue("-110", "KBETR");// 单价
			it_condition.setValue("1", "KPEIN");// 条件定价单位

			it_condition.appendRow();
			it_condition.setRow(4);

			it_condition.setValue("0080000159", "VBELN");// 交货单号
			it_condition.setValue("2000", "POSNR");// 交货行项目
			it_condition.setValue("ZPR1", "KSCHL");// 条件类型
			it_condition.setValue("9.18", "KBETR");// 单价
			it_condition.setValue("1", "KPEIN");// 条件定价单位

			if (mConnection == null) {
				System.out.println("mConnection 为空");
			}

			mConnection.execute(function);

			JCO.Table ET_LOG = function.getTableParameterList().getTable(
					"ET_MESSAGE");

			JCO.ParameterList output = function.getExportParameterList();

			String msg = "";

			// 判断是否成功写日志
			System.out.println(output.getString("EV_SUBRC"));
			System.out.println(output.getString("EV_MSG"));

			if (output.getString("EV_SUBRC").equals("0")) {

				System.out.println(output.getString("EV_VBELN"));
				System.out.println(output.getString("EV_BELNR"));

			} else {
				for (int m = 0; m < ET_LOG.getNumRows(); m++) {
					ET_LOG.setRow(m);
					msg = msg + ET_LOG.getString("MESSAGE") + ";";
				}
				System.out.println(msg);

			}

		} catch (Exception ex) {

			ex.printStackTrace();

		} finally {
			if (mConnection != null) {
				mConnection.disconnect();
			}

		}

	}

	*//**
	 * 读1500整机与内外机配套关系
	 * 
	 * @throws Exception
	 * *//*
	public String getZRFC_SCM_READ_CS03(String ip_matnr) throws Exception {

		String item_code = "";// 物料编码
		if (this.db_connect(SCM_CS03) == 2) {

			int pro_type = 0;
			JCO.Function function = null;
			JCO.Table ztmtrack = null;
			try {
				// getConnection();
				function = createFunction(SCM_CS03); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_CS03 + "在sap中没有发现");
				} else {

					*//**
					 *输入要读取物料号码
					 * *//*
					JCO.ParameterList input = function.getImportParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
					input.setValue(ip_matnr, "IV_MATNR");// 物料号码
					input.setValue("1100", "IV_WERKS");// 工厂
					input.setValue("5", "IV_STLAN");// BOM用途
					input.setValue("01", "IV_STLAL");// 可选的BOM

					JCO.ParameterList list = function.getTableParameterList();
					mConnection.execute(function);

					ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。

					if (ztmtrack.getNumRows() > 0) {
						for (int i = 0; i < ztmtrack.getNumRows(); i++) {
							ztmtrack.setRow(i);// 指定行

							// type_id=3 移动空调
							// type_id=1 内机
							// type_id=2 外机
							String sql = "select * from  psc_item where usable=2 and psc_item_code='"
									+ ztmtrack.getString("IDNRK") + "'";
							Hashtable htpsc = this.getPdmDataCentre()
									.oneRowSelect(sql);

							if (htpsc != null) {
								if (Integer.parseInt((String) htpsc
										.get("type_id")) == 1) {
									pro_type = 2;
								} else if (Integer.parseInt((String) htpsc
										.get("type_id")) == 2) {
									pro_type = 3;
								} else if (Integer.parseInt((String) htpsc
										.get("type_id")) == 3) {
									pro_type = 3;
								}
							}

							sql = "select count(*) from psc_item where usable=2 and psc_item_code='"
									+ ztmtrack.getString("IDNRK") + "'";
							if (this.getPdmDataCentre().intSelect(sql) == 0
									&& pro_type == 2) {
								throw new IllegalLogicException("此整机编码【"
										+ ip_matnr + "】对应的内机编码【"
										+ ztmtrack.getString("IDNRK")
										+ "】在PDM系统不存在！");
							}
							if (this.getPdmDataCentre().intSelect(sql) == 0
									&& pro_type == 3) {
								throw new IllegalLogicException("此整机编码【"
										+ ip_matnr + "】对应的外机编码【"
										+ ztmtrack.getString("IDNRK")
										+ "】在PDM系统不存在！");
							}

							com.dmcrm.proman.Base_Pro_Item bp = new com.dmcrm.proman.Base_Pro_Item();
							bp.setParent(this);
							sql = "select nvl(Item_id,0)item_id from Base_Pro_Item where Item_Code='"
									+ ztmtrack.getString("IDNRK") + "'";
							Hashtable ht = this.getDataCentre().oneRowSelect(
									sql);
							if (ht == null || ht.size() == 0) {

								bp.Item_Code = ztmtrack.getString("IDNRK");
								bp.Item_Name = ztmtrack.getString("MAKTX");
								bp.Usable = 2;
								bp.EntId = 101;
								bp.Item_Kind = 0;
								bp.Pro_Type = pro_type;
								bp.Uom_Code = "01";
								bp.Uom_Id = 43;
								bp.Uom_Name = "台";
								bp.doInsert();
							} else {
								bp.Item_Id = Integer.parseInt((String) ht
										.get("item_id"));
								bp.Item_Code = ztmtrack.getString("IDNRK");
								bp.Item_Name = ztmtrack.getString("MAKTX");
								bp.Usable = 2;
								bp.EntId = 101;
								bp.Item_Kind = 0;
								bp.Pro_Type = pro_type;
								bp.Uom_Code = "01";
								bp.Uom_Id = 43;
								bp.Uom_Name = "台";
								bp.doUpdate();
							}

						}
					} else {
						String sql = "update pro_item_header set usable=1 "
								+ " where item_h_name not like '%移动空调%'  and item_h_code='"
								+ ip_matnr + "'";
						this.getDataCentre().update(sql);
					}
					if (ztmtrack.getNumRows() > 0) {
						for (int i = 0; i < ztmtrack.getNumRows(); i++) {
							ztmtrack.setRow(i);// 指定行
							if (item_code == "") {
								item_code = "'" + ztmtrack.getString("IDNRK")
										+ "'";// 物料编码
							} else {
								item_code = item_code + ",'"
										+ ztmtrack.getString("IDNRK") + "'";// 物料编码
							}

						}
					}

				}
			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());
			} finally {
				// if (mConnection != null) {
				// mConnection.disconnect();
				// }
				//
			}

		}
		return item_code;
	}

	*//**
	 *创建销售订单交货单 VL02N
	 * *//*
	public void ZIF_OMS_DELIVERY_POST_VL02N(Hashtable ht, String iv_vbeln)
			throws SinocpcException {

		String sql = "";
		if (this.db_connect(SCM_VL02N) == 2) {
			JCO.Function function = null;
			try {
				getConnection();

				function = createFunction(SCM_VL02N); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_VL02N + "在sap中没有发现");
				}

				*//**
				 * VL02N创建外向交货订单及发货过帐输入
				 * *//*
				JCO.ParameterList input = function.getImportParameterList();
				input.setValue(iv_vbeln, "IV_VBELN");// 销售与分销单据号输入80000325
														// 输入发货单号 没有截取前面的 00
				input.setValue((String) ht.get("iv_date"), "IV_DATE");// 实际货物移动日期

				input.setValue("X", "IV_FLAG");// 自动过帐货物移动"X"

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);

				JCO.Table ET_LOG = function.getTableParameterList().getTable(
						"ET_MESSAGE");
				String msg = "";

				JCO.ParameterList output = function.getExportParameterList();
				output.getValue("EV_MSG");

				System.out.println(output.getString("EV_SUBRC"));
				if (output.getString("EV_SUBRC").equals("0")) {
					sql = "update sale_ship_notice_sap_line set outno_sap='"
							+ output.getString("EV_MBLNR") + "'"
							+ " where notice_id="
							+ Integer.parseInt((String) ht.get("notice_id"))
							+ " and delorder_sap='" + iv_vbeln + "'";
					this.getDataCentre().update(sql);

					// System.out.println(output.getString("EV_MBLNR"));
				} else {
					for (int m = 0; m < ET_LOG.getNumRows(); m++) {
						ET_LOG.setRow(m);
						msg = msg + ET_LOG.getString("ARKTX") + ";";
					}
					System.out.println(msg);
					throw new IllegalLogicException(msg);

				}

			} catch (Exception ex) {
				// this.getDataCentre().commit();
				ex.printStackTrace();
				// throw new IllegalLogicException(ex.toString());
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}

	}

	public void putZRFC_SD_WRITE_VA011() throws SinocpcException {

		String sql = "";
		String doc_type = "";
		if (this.db_connect(SCM_VA01) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_VA01);

				if (function == null) {
					System.out.println(SCM_VA01 + "在sap中没有发现");
				} else {

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*
					JCO.Structure ip_header = function.getImportParameterList()
							.getStructure("IS_HEADER"); // 获取import抬头结构

					ip_header.setValue("ZOR7", "DOC_TYPE"); // 销售单据类型ZIN ZS00

					ip_header.setValue("1130", "SALES_ORG"); // 销售组织
					ip_header.setValue("167", "SALES_GRP"); // 销售组-- 大区
					ip_header.setValue("1013", "SALES_OFF"); // 销售部门--部门
					ip_header.setValue("30", "DISTR_CHAN");// 分销渠道
					ip_header.setValue("10", "DIVISION"); // 部门

					ip_header.setValue("20121128", "PURCH_DATE");// 客户订单日期
					ip_header.setValue("PI181211010", "PURCH_NO_C");// 订单号

					ip_header.setValue("USD", "CURRENCY"); // 货币代码
					ip_header.setValue("20130202", "REQ_DATE_H");// 请求交货日期默认采购单日期

					ip_header.setValue("FOB", "INCOTERMS1");// 付款条款price_type_name
					ip_header.setValue("以色列", "INCOTERMS2");// 目的国
					ip_header.setValue("ISRAEL", "REF_1");// 业务员名字
					ip_header.setValue("W005", "PMNTTRMS");// 收付条件代码
					ip_header.setValue("X", "ORDCOMB_IN");// 订单组合标识

					// sql=" select dictname from cpcdict "
					// +" where dictcode like '%ERP_Type_Id%'  "
					// +" and  dictvalue= "+(String)hth.get("erp_type_id");
					// String dictname=this.getDataCentre().strSelect(sql);
					// ip_header.setValue("C","PYMT_METH");//付款方式
					ip_header.setValue("Z001", "S_PROC_IND");// 特殊处理标志

					// 更改参数
					JCO.Structure is_obj_created_info = function
							.getImportParameterList().getStructure(
									"IS_OBJ_CREATED_INFO");
					is_obj_created_info.setValue("OMS", "SOURCE_SYS");// 源系统
					is_obj_created_info.setValue("4F73924018", "OBJ_TYP");// 对象类型
					is_obj_created_info.setValue("4F73924018", "OBJ_KEY_EXT");// 对象关键字
					is_obj_created_info.setValue("XXXX", "CREATED_BY_EXT");// 创建对象的人员名称

					*//**
					 * 出具发票冻结（X表示需要修改，空表示不需要） 队列 PUTQ 激活标志 销售单位目标总数量
					 * *//*
					JCO.ParameterList input = function.getImportParameterList();
					input.setValue("0001", "IV_TRATY");// 运输方式类型
					input.setValue("4F73924018", "IV_VBELN");// 销售凭证

					*//**
					 * 通讯字段: 销售和分销凭证项目
					 * *//*

					JCO.ParameterList list = function.getTableParameterList();
					JCO.Table it_item = list.getTable("IT_ITEM"); // 是一个内表。

					it_item.appendRow();
					it_item.setRow(1);

					it_item.setValue("1", "ITM_NUMBER");// 销售单据项目
					it_item.setValue("4F7392367602N", "MATERIAL"); // 物料号码
					it_item.setValue("1100", "PLANT"); // 工厂
					it_item.setValue("Baymak,Baxi", "CUST_MAT35"); // 品牌
					it_item.setValue("1391", "STORE_LOC"); // 库存地点（如果是录入整机则不能录入）
					// 如果物料是配件并且价格等于0 ,则需要指定该物料属于那一个上层项目
					it_item.setValue("", "HG_LV_ITEM"); // 物料单结构中的上层项目（如果是整机下的内外机则必须录入）
					it_item.setValue("", "ITEM_CATEG");
					it_item.setValue("200", "TARGET_QTY"); // 销售单位目标数量
					it_item.setValue("", "ALTERN_BOM"); // 可选的BOM 必须录
					it_item.setValue("", "ORDERID");// 订单号
					it_item.setValue("", "BATCH");// 批次编号

					*//**
					 * 通讯字段: SD单据合作伙伴:WWW
					 * *//*

					JCO.Table it_partners = list.getTable("IT_PARTNERS"); // 是一个内表。IT_PARTNERS
					it_partners.appendRow();

					it_partners.setRow(1);
					it_partners.setValue("SP", "PARTN_ROLE");// 合作伙伴功能
					it_partners.setValue("500309", "PARTN_NUMB");// 购货方编号

					it_partners.setRow(2);
					it_partners.setValue("WE", "PARTN_ROLE");// 合作伙伴功能
					it_partners.setValue("500309", "PARTN_NUMB");// 购货方编号

					*//**
					 * 维护订单条件的通讯字段
					 * *//*

					JCO.Table it_conditions = list.getTable("IT_CONDITIONS");

					it_conditions.appendRow();
					it_conditions.setRow(1);

					it_conditions.setValue("1", "ITM_NUMBER");// 条件项目号
					it_conditions.setValue("ZPR1", "COND_TYPE");// 条件类型
					it_conditions.setValue("200", "COND_VALUE");// 定价比率
					it_conditions.setValue("USD", "CURRENCY");// 货币代码
					it_conditions.setValue("1", "COND_P_UNT");// 条件定价单位

					*//**
					 * 维护 SD 凭证计划行的通讯字段
					 * *//*
					JCO.Table it_schedules = list.getTable("IT_SCHEDULES");

					it_schedules.appendRow();
					it_schedules.setRow(1);
					it_schedules.setValue("1", "ITM_NUMBER");// 销售单据项目
					it_schedules.setValue("200", "REQ_QTY");// 以销售单位计的订单数量
					it_schedules.setValue("20130110", "REQ_DATE");// 计划行日期

					*//**
					 * 通讯字段：SD 文本
					 * *//*
					// JCO.Table it_text = list.getTable("IT_TEXT");
					// it_text.appendRow();
					// it_text.setRow(1);
					// it_text.setValue("","ITM_NUMBER");//销售单据项目
					// it_text.setValue("","TEXT_ID"); //文本 ID
					// it_text.setValue("","LANGU"); //文本 ID
					// it_text.setValue("","TEXT_LINE"); //文本 ID

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}

					mConnection.execute(function);
					JCO.ParameterList output = function
							.getExportParameterList();
					output.getValue("EV_MSG");
					JCO.Table ET_LOG = function.getTableParameterList()
							.getTable("ET_LOG");
					String msg = "";

					if (function.getExportParameterList().getString("EV_SUBRC")
							.equals("0")) {

						throw new IllegalLogicException("成功！");

					} else {

						for (int m = 0; m < ET_LOG.getNumRows(); m++) {
							ET_LOG.setRow(m);
							msg = msg + ET_LOG.getString("MESSAGE") + ";";
						}
						throw new IllegalLogicException(msg);

					}

				}

			} catch (Exception ex) {
				// this.getDataCentre().commit();
				ex.printStackTrace();

				throw new IllegalLogicException(ex.toString());
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}

	}

	*//**
	 * 创建销售订单
	 * *//*
	public void putZRFC_SD_WRITE_VA01(Vector vc, Hashtable hth, String line_type)
			throws SinocpcException {
		String sql = "";
		// String doc_type="";
		if (this.db_connect(SCM_VA01) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_VA01);

				if (function == null) {
					System.out.println(SCM_VA01 + "在sap中没有发现");
				} else {

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*
					JCO.Structure ip_header = function.getImportParameterList()
							.getStructure("IS_HEADER"); // 获取import抬头结构

					ip_header.setValue("ZOR7", "DOC_TYPE"); // 销售单据类型ZIN ZS00

					ip_header.setValue((String) hth.get("sales_org"),
							"SALES_ORG"); // 销售组织
					ip_header.setValue((String) hth.get("sap_org_code"),
							"SALES_GRP"); // 销售组-- 大区
					ip_header.setValue((String) hth.get("sap_zone_code"),
							"SALES_OFF"); // 销售部门--部门
					ip_header.setValue("30", "DISTR_CHAN");// 分销渠道
					ip_header.setValue("10", "DIVISION"); // 部门

					ip_header.setValue((String) hth.get("check_time"),
							"PURCH_DATE");// 客户订单日期
					ip_header.setValue((String) hth.get("pi_no"), "PURCH_NO_C");// 订单号

					ip_header.setValue((String) hth.get("currency_code"),
							"CURRENCY"); // 货币代码
					ip_header.setValue((String) hth.get("check_time"),
							"REQ_DATE_H");// 请求交货日期默认采购单日期
					sql = "select telzone from cpcarea where areaid="
							+ Integer.parseInt((String) hth.get("area_id"));
					String telzone = this.getDataCentre().strSelect(sql);
					ip_header.setValue((String) hth.get("price_type_name"),
							"INCOTERMS1");// 付款条款price_type_name
					ip_header.setValue(telzone, "INCOTERMS2");// 目的国
					ip_header.setValue((String) hth.get("sales_user_id"),
							"REF_1");// 业务员名字
					ip_header.setValue((String) hth.get("pay_condition"),
							"PMNTTRMS");// 收付条件代码
					ip_header.setValue("X", "ORDCOMB_IN");// 订单组合标识

					sql = " select dictname from cpcdict "
							+ " where dictcode like '%ERP_Type_Id%'  "
							+ " and  dictvalue= "
							+ (String) hth.get("erp_type_id");
					String dictname = this.getDataCentre().strSelect(sql);
					// ip_header.setValue("C","PYMT_METH");//付款方式
					ip_header.setValue("Z001", "S_PROC_IND");// 特殊处理标志

					// 更改参数
					JCO.Structure is_obj_created_info = function
							.getImportParameterList().getStructure(
									"IS_OBJ_CREATED_INFO");
					is_obj_created_info.setValue("OMS", "SOURCE_SYS");// 源系统
					is_obj_created_info.setValue((String) hth
							.get("inspection_batchno"), "OBJ_TYP");// 对象类型
					is_obj_created_info.setValue((String) hth
							.get("inspection_batchno"), "OBJ_KEY_EXT");// 对象关键字
					is_obj_created_info.setValue(this.getUserBean().UserId,
							"CREATED_BY_EXT");// 创建对象的人员名称

					*//**
					 * 出具发票冻结（X表示需要修改，空表示不需要） 队列 PUTQ 激活标志 销售单位目标总数量
					 * *//*
					JCO.ParameterList input = function.getImportParameterList();
					input.setValue("0001", "IV_TRATY");// 运输方式类型
					input.setValue((String) hth.get("inspection_batchno"),
							"IV_VBELN");// 销售凭证

					*//**
					 * 通讯字段: 销售和分销凭证项目
					 * *//*

					JCO.ParameterList list = function.getTableParameterList();
					JCO.Table it_item = list.getTable("IT_ITEM"); // 是一个内表。

					for (int i = 0; i < vc.size(); i++) {
						Hashtable ht = (Hashtable) vc.elementAt(i);

						it_item.appendRow();
						it_item.setRow(i + 1);

						it_item.setValue((String) ht.get("seq"), "ITM_NUMBER");// 销售单据项目
						it_item.setValue((String) ht.get("erp_code"),
								"MATERIAL"); // 物料号码
						it_item.setValue((String) ht.get("plant"), "PLANT"); // 工厂
						it_item.setValue((String) ht.get("brand_name"),
								"CUST_MAT35"); // 品牌
						it_item.setValue((String) ht.get("store_loc"),
								"STORE_LOC"); // 库存地点（如果是录入整机则不能录入）
						// 如果物料是配件并且价格等于0 ,则需要指定该物料属于那一个上层项目
						it_item.setValue("", "HG_LV_ITEM"); // 物料单结构中的上层项目（如果是整机下的内外机则必须录入）
						it_item.setValue("", "ITEM_CATEG");
						it_item.setValue((String) ht.get("qty"), "TARGET_QTY"); // 销售单位目标数量
						it_item.setValue("", "ALTERN_BOM"); // 可选的BOM 必须录
						it_item.setValue("", "ORDERID");// 订单号
						it_item.setValue("", "BATCH");// 批次编号
					}

					*//**
					 * 通讯字段: SD单据合作伙伴:WWW
					 * *//*

					JCO.Table it_partners = list.getTable("IT_PARTNERS"); // 是一个内表。IT_PARTNERS
					it_partners.appendRow();

					it_partners.setRow(1);
					it_partners.setValue("SP", "PARTN_ROLE");// 合作伙伴功能
					it_partners.setValue((String) hth.get("cust_code"),
							"PARTN_NUMB");// 购货方编号

					it_partners.setRow(2);
					it_partners.setValue("WE", "PARTN_ROLE");// 合作伙伴功能
					it_partners.setValue((String) hth.get("cust_code"),
							"PARTN_NUMB");// 购货方编号

					*//**
					 * 维护订单条件的通讯字段
					 * *//*

					JCO.Table it_conditions = list.getTable("IT_CONDITIONS");

					for (int i = 0; i < vc.size(); i++) {
						Hashtable ht = (Hashtable) vc.elementAt(i);
						it_conditions.appendRow();
						it_conditions.setRow(i + 1);

						String price = (String) ht.get("price");

						if (!price.equals("0")) {

							it_conditions.setValue((String) ht.get("seq"),
									"ITM_NUMBER");// 条件项目号
							it_conditions.setValue("ZPR1", "COND_TYPE");// 条件类型
							it_conditions.setValue(price, "COND_VALUE");// 定价比率
							it_conditions.setValue((String) ht
									.get("currency_code"), "CURRENCY");// 货币代码
							it_conditions.setValue("1", "COND_P_UNT");// 条件定价单位
						}

					}

					*//**
					 * 维护 SD 凭证计划行的通讯字段
					 * *//*
					JCO.Table it_schedules = list.getTable("IT_SCHEDULES");
					for (int i = 0; i < vc.size(); i++) {
						Hashtable ht = (Hashtable) vc.elementAt(i);

						it_schedules.appendRow();
						it_schedules.setRow(i + 1);
						it_schedules.setValue((String) ht.get("seq"),
								"ITM_NUMBER");// 销售单据项目
						it_schedules
								.setValue((String) ht.get("qty"), "REQ_QTY");// 以销售单位计的订单数量
						it_schedules.setValue((String) ht.get("deliver_date"),
								"REQ_DATE");// 计划行日期

					}

					*//**
					 * 通讯字段：SD 文本
					 * *//*
					// JCO.Table it_text = list.getTable("IT_TEXT");
					// it_text.appendRow();
					// it_text.setRow(1);
					// it_text.setValue("","ITM_NUMBER");//销售单据项目
					// it_text.setValue("","TEXT_ID"); //文本 ID
					// it_text.setValue("","LANGU"); //文本 ID
					// it_text.setValue("","TEXT_LINE"); //文本 ID

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}

					mConnection.execute(function);
					JCO.ParameterList output = function
							.getExportParameterList();
					output.getValue("EV_MSG");
					JCO.Table ET_LOG = function.getTableParameterList()
							.getTable("ET_LOG");
					String msg = "";

					if (function.getExportParameterList().getString("EV_SUBRC")
							.equals("0")) {

						sql = "update sale_prod_line set sap_no='"
								+ (String) hth.get("inspection_batchno") + "'"
								+ " where prod_id="
								+ Integer.parseInt((String) hth.get("prod_id"))
								+ " and line_type in(" + line_type + ")";
						this.getDataCentre().update(sql);

						// 先删除
						sql = "delete sale_prod_sap\n"
								+ " where prod_id ="
								+ Integer.parseInt((String) hth.get("prod_id"))
								+ "   and erp_code in\n"
								+ "       (select n.erp_code\n"
								+ "          from sale_prod_header m, sale_prod_line n\n"
								+ "         where m.prod_id = n.prod_id\n"
								+ "           and m.prod_id ="
								+ Integer.parseInt((String) hth.get("prod_id"))
								+ "           and n.line_type in(" + line_type
								+ "))";
						this.getDataCentre().execute(sql);

						if (!line_type.equals("4")) {
							// 再插入
							sql = " insert into sale_prod_sap  "
									+ " select m.prod_no,m.prod_id,m.pi_no,m.pi_id, n.prod_qty qty,n.price,n.erp_code,n.cust_spec, "
									+ " rownum seq,m.currency_code,n.deliver_date,"
									+ "'"
									+ (String) hth.get("inspection_batchno")
									+ "' iv_vbeln,n.prod_line_id from sale_prod_header m,  sale_prod_line n "
									+ " where m.prod_id=n.prod_id and n.prod_qty>0 "
									+ " and m.prod_id="
									+ Integer.parseInt((String) hth
											.get("prod_id"))
									+ " and n.line_type in(" + line_type + ")"
									+ " order by n.pro_type, n.prod_line_id ";
							this.getDataCentre().execute(sql);
						} else {
							sql = " insert into sale_prod_sap "
									+ " select prod_no,prod_id,pi_no,pi_id, qty,price,erp_code,cust_spec,  "
									+ " rownum+(select nvl(max(seq),0) from sale_prod_sap  "
									+ " where prod_id="
									+ Integer.parseInt((String) hth
											.get("prod_id"))
									+ " ) seq, "
									+ "  currency_code,deliver_date, "
									+ " inspection_batchno iv_vbeln,0 prod_line_id "
									+ " from (select m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty qty, "
									+ " t.price,n.erp_code,n.cust_spec,c.brand_name,    "
									+ " case when m.sale_ent_type=2 then '1300' else '1391' end store_loc,  "
									+ " case when m.sale_ent_type=2 then '1130' else '1100' end plant,  "
									+ " m.currency_code,n.deliver_date ,m.inspection_batchno  "
									+ " from sale_prod_header m,sale_prod_h_line c , sale_prod_line n ,sale_prod_package t   "
									+ " where m.prod_id=n.prod_id   "
									+ " and m.prod_id=c.prod_id   "
									+ " and n.prod_h_id=c.prod_h_id   "
									+ " and m.prod_id=t.prod_id      "
									+ " and t.pack_qty>0       "
									+ " and m.prod_id="
									+ Integer.parseInt((String) hth
											.get("prod_id"))
									+ " and nvl(n.line_type,0)=4  "
									+ " group by m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty ,m.inspection_batchno,  "
									+ " t.price,n.erp_code,n.cust_spec,c.brand_name,c.CUST_ITEM_NAME,n.deliver_date,   "
									+ " m.sale_ent_type	,m.currency_code,rownum   "
									+ " order by deliver_date  ) where   rownum=1   ";
							this.getDataCentre().execute(sql);
						}

						sql = "update sale_prod_header set is_sap=2 "
								+ " where prod_id="
								+ Integer.parseInt((String) hth.get("prod_id"));
						this.getDataCentre().update(sql);

					} else {

						for (int m = 0; m < ET_LOG.getNumRows(); m++) {
							ET_LOG.setRow(m);
							msg = msg + ET_LOG.getString("MESSAGE") + ";";
						}
						throw new IllegalLogicException(msg);

					}

				}

			} catch (Exception ex) {
				// this.getDataCentre().commit();
				ex.printStackTrace();
				throw new IllegalLogicException("SAP提示错误:接口名<" + SCM_VA01 + ">"
						+ ex.toString());
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}
	}

	*//**
	 * 创建借项销售订单
	 * *//*
	public void putZIF_OMS_SALESDOCU_CREATEFROMDA() throws SinocpcException {
		String sql = "";
		String doc_type = "";

		JCO.Function function = null;
		try {
			getConnection();
			function = createFunction(SCM_VA01JX);

			if (function == null) {
				System.out.println(SCM_VA01JX + "在sap中没有发现");
			} else {

				*//**
				 * 通讯字段: 销售和分销凭证抬头
				 * *//*
				JCO.Structure ip_header = function.getImportParameterList()
						.getStructure("IS_ORDER_HEADER"); // 获取import抬头结构

				ip_header.setValue("ZDR", "DOC_TYPE"); // 销售单据类型ZIN ZS00

				ip_header.setValue("1130", "SALES_ORG"); // 销售组织
				ip_header.setValue("131", "SALES_GRP"); // 销售组-- 大区
				ip_header.setValue("1012", "SALES_OFF"); // 销售部门--部门
				ip_header.setValue("30", "DISTR_CHAN");// 分销渠道
				ip_header.setValue("10", "DIVISION"); // 部门

				ip_header.setValue("20120928", "PURCH_DATE");// 客户订单日期
				ip_header.setValue("PI09000001", "PURCH_NO_C");// 订单号

				ip_header.setValue("USD", "CURRENCY"); // 货币代码
				ip_header.setValue("20120928", "REQ_DATE_H");// 请求交货日期默认采购单日期

				ip_header.setValue("10", "ORD_REASON");

				*//**
				 * 通讯字段: 销售和分销凭证项目
				 * *//*

				JCO.ParameterList list = function.getTableParameterList();
				JCO.Table it_item = list.getTable("IT_ORDER_ITEM"); // 是一个内表。

				it_item.appendRow();
				it_item.setRow(1);

				it_item.setValue("1000", "ITM_NUMBER");// 销售单据项目
				it_item.setValue("4F7392302301W", "MATERIAL"); // 物料号码
				it_item.setValue("1100", "PLANT"); // 工厂
				// it_item.setValue("1570", "STORE_LOC"); //库存地点（如果是录入整机则不能录入）
				// 如果物料是配件并且价格等于0 ,则需要指定该物料属于那一个上层项目
				it_item.setValue("1", "TARGET_QTY"); // 销售单位目标数量
				it_item.setValue("388", "COND_VALUE");// 订单号
				it_item.setValue("ZPR1", "COND_TYPE");// 批次编号

				*//**
				 * 通讯字段: SD单据合作伙伴:WWW
				 * *//*

				JCO.Table it_partners = list.getTable("IT_ORDER_PARTERS"); // 是一个内表。IT_PARTNERS
				it_partners.appendRow();

				it_partners.setRow(1);
				it_partners.setValue("AG", "PARTN_ROLE");// 合作伙伴功能
				it_partners.setValue("500009", "PARTN_NUMB");// 购货方编号

				// it_partners.setRow(2);
				// it_partners.setValue("AG","PARTN_ROLE");//合作伙伴功能
				// it_partners.setValue("500009","PARTN_NUMB");//购货方编号
				//						

				// it_partners.appendRow();
				// it_partners.setRow(3);
				// it_partners.setValue("", "PARTN_ROLE"); //合作伙伴功能
				// it_partners.setValue("", "PARTN_NUMB"); //购货方编号
				//											

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);
				JCO.ParameterList output = function.getExportParameterList();

				output.getValue("EV_MSG");

				System.out.println(output.getValue("EV_SUBRC"));
				if (function.getExportParameterList().getString("EV_SUBRC")
						.equals("0")) {
					System.out.println(output.getValue("EV_VBELN"));

				}

				System.out.println(output.getValue("ES_RETURN"));

			}

		} catch (Exception ex) {
			this.getDataCentre().commit();
			ex.printStackTrace();

		} finally {
			if (mConnection != null) {
				mConnection.disconnect();
			}

		}
	}

	*//**
	 * 修改销售订单
	 * *//*
	public void putZIF_OMS_SALESORDER_CHANGE_VA02(Vector vcqty,
			String iv_vbeln, int type, String incoterms1, String incoterms2,
			String pmnttrms, String pymt_meth, int prod_id)
			throws SinocpcException {
		if (this.db_connect(SCM_VA02) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_VA02);

				if (function == null) {
					System.out.println(SCM_VA02 + "在sap中没有发现");
				} else {

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*
					JCO.ParameterList input = function.getImportParameterList();
					input.setValue(iv_vbeln, "IV_VBELN");// 修改的销售单号

					*//**
					 * 通讯字段: 销售和分销凭证抬头
					 * *//*
					if (type == 1) {
						JCO.Structure ip_header = function
								.getImportParameterList().getStructure(
										"IS_HEADER_IN"); // 获取import抬头结构

						JCO.Structure is_header_inx = function
								.getImportParameterList().getStructure(
										"IS_HEADER_INX"); // 获取import抬头结构
						if (incoterms1 != null && incoterms1 != ""
								&& incoterms2 != null && incoterms2 != "") {

							ip_header.setValue(incoterms1, "INCOTERMS1"); // 国际贸易条件
							is_header_inx.setValue("X", "INCOTERMS1"); // 国际贸易条件

							ip_header.setValue(incoterms2, "INCOTERMS2"); // 目的国
							is_header_inx.setValue("X", "INCOTERMS2"); // 目的国
							is_header_inx.setValue("U", "UPDATEFLAG"); // 修改标志
						}
						if (pmnttrms != null && pmnttrms != "") {
							ip_header.setValue(pmnttrms, "PMNTTRMS"); // 付款条款
							is_header_inx.setValue("X", "PMNTTRMS"); // 付款条款

							// ip_header.setValue(pymt_meth,"PYMT_METH"); //
							// 付款方式
							// is_header_inx.setValue("X","PYMT_METH"); // 付款方式
							is_header_inx.setValue("U", "UPDATEFLAG"); // 修改标志
						}

					}

					JCO.ParameterList list = function.getTableParameterList();
					*//**
					 * 单价修改内表
					 * *//*

					if (type == 2) {

						JCO.Table it_items = list.getTable("IT_ITEMS"); // 是一个内表。

						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);
								it_items.appendRow();
								it_items.setRow(i + 1);

								it_items.setValue((String) ht.get("seq"),
										"POSNR");// 销售单据项目
								it_items.setValue((String) ht.get("price"),
										"KBETR"); // 单价
							}

						}
					}

					*//**
					 * 数量修改内表
					 * *//*
					if (type == 3) {

						JCO.Table it_schdl = list.getTable("IT_SCHDL"); // 是一个内表。IT_PARTNERS

						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);

								it_schdl.appendRow();
								it_schdl.setRow(i + 1);

								it_schdl.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售凭证项目
								it_schdl.setValue("0001", "SCHED_LINE");// 交货计划行号
								it_schdl.setValue((String) ht.get("qty"),
										"REQ_QTY");// 修改之后的数量
								it_schdl.setValue((String) ht
										.get("deliver_date"), "REQ_DATE");// 修改交期

							}
						}

						JCO.Table it_schdlx = list.getTable("IT_SCHDLX"); // 是一个内表。IT_PARTNERS\

						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);
								it_schdlx.appendRow();
								it_schdlx.setRow(i + 1);

								it_schdlx.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售凭证项目
								it_schdlx.setValue("0001", "SCHED_LINE");// 交货计划行号
								it_schdlx.setValue("U", "UPDATEFLAG");// 更新标识
								it_schdlx.setValue("X", "REQ_QTY");// 修改之后的数量
								it_schdlx.setValue("X", "REQ_DATE");// 修改交期

							}
						}

					} // 新增一行配件
					if (type == 4) {

						JCO.Table it_schdl = list.getTable("IT_SCHDL"); // 是一个内表。IT_PARTNERS

						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);

								it_schdl.appendRow();
								it_schdl.setRow(i + 1);
								it_schdl.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售凭证项目
								it_schdl.setValue("0001", "SCHED_LINE");// 交货计划行号
								it_schdl.setValue((String) ht.get("qty"),
										"REQ_QTY");// 修改之后的数量
							}
						}

						JCO.Table it_schdlx = list.getTable("IT_SCHDLX"); // 是一个内表。IT_PARTNERS\

						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);
								it_schdlx.appendRow();
								it_schdlx.setRow(i + 1);
								it_schdlx.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售凭证项目
								it_schdlx.setValue("0001", "SCHED_LINE");// 交货计划行号
								it_schdlx.setValue("I", "UPDATEFLAG");// 更新标识
								it_schdlx.setValue("X", "REQ_QTY");// 修改之后的数量
							}
						}

						JCO.Table it_item = list.getTable("IT_ITEM");// 产品数据

						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);
								it_item.appendRow();
								it_item.setRow(i + 1);
								it_item.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售单据项目
								it_item.setValue((String) ht.get("erp_code"),
										"MATERIAL"); // 物料号码
								it_item.setValue((String) ht.get("plant"),
										"PLANT"); // 工厂
								it_item.setValue((String) ht.get("brand_name"),
										"CUST_MAT35"); // 品牌
								it_item.setValue((String) ht.get("store_loc"),
										"STORE_LOC"); // 库存地点（如果是录入整机则不能录入）
								it_item.setValue((String) ht.get("qty"),
										"TARGET_QTY"); // 销售单位目标数量

							}
						}

						JCO.Table it_itemx = list.getTable("IT_ITEMX");
						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);
								it_itemx.appendRow();
								it_itemx.setRow(i + 1);
								it_itemx.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售单据项目
								it_itemx.setValue("I", "UPDATEFLAG"); // 新增标志
								it_itemx.setValue("X", "MATERIAL"); // 物料号码
								it_itemx.setValue("X", "PLANT"); // 工厂
								it_itemx.setValue("X", "CUST_MAT35"); // 品牌
								it_itemx.setValue("X", "STORE_LOC"); // 库存地点（如果是录入整机则不能录入）
								it_itemx.setValue("X", "TARGET_QTY"); // 销售单位目标数量

							}
						}

						JCO.Table it_conditions = list
								.getTable("IT_CONDITIONS");

						for (int i = 0; i < vcqty.size(); i++) {
							Hashtable ht = (Hashtable) vcqty.elementAt(i);
							it_conditions.appendRow();
							it_conditions.setRow(i + 1);

							String price = (String) ht.get("price");

							if (!price.equals("0")) {

								it_conditions.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 条件项目号
								it_conditions.setValue("ZPR1", "COND_TYPE");// 条件类型
								it_conditions.setValue(price, "COND_VALUE");// 定价比率
								it_conditions.setValue((String) ht
										.get("currency_code"), "CURRENCY");// 货币代码
								it_conditions.setValue("1", "COND_P_UNT");// 条件定价单位
							}

						}

						JCO.Table it_conditionsx = list
								.getTable("IT_CONDITIONSX");
						for (int i = 0; i < vcqty.size(); i++) {
							Hashtable ht = (Hashtable) vcqty.elementAt(i);
							it_conditionsx.appendRow();
							it_conditionsx.setRow(i + 1);

							String price = (String) ht.get("price");

							if (!price.equals("0")) {

								it_conditionsx.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 条件项目号
								it_conditionsx.setValue("I", "UPDATEFLAG"); // 新增标志
								it_conditionsx.setValue("X", "COND_TYPE");// 条件类型
								it_conditionsx.setValue("X", "COND_VALUE");// 定价比率
								it_conditionsx.setValue("X", "CURRENCY");// 货币代码
								it_conditionsx.setValue("X", "COND_P_UNT");// 条件定价单位
							}

						}

					}
					if (type == 5) {
						// if(1==1)throw new IllegalLogicException("2222");
						JCO.Table it_item = list.getTable("IT_ITEM");// 产品数据

						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);
								it_item.appendRow();
								it_item.setRow(i + 1);
								it_item.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售单据项目
								it_item.setValue("10", "REASON_REJ"); // 拒绝原因

							}
						}

						JCO.Table it_itemx = list.getTable("IT_ITEMX");
						if (vcqty.size() > 0) {
							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);
								it_itemx.appendRow();
								it_itemx.setRow(i + 1);
								it_itemx.setValue((String) ht.get("seq"),
										"ITM_NUMBER");// 销售单据项目
								it_itemx.setValue("U", "UPDATEFLAG"); // 修改标志
								it_itemx.setValue("X", "REASON_REJ"); // 拒绝原因

							}
						}
					}

					if (mConnection == null) {
						System.out.println("mConnection 为空");
					}

					mConnection.execute(function);

					JCO.Table ET_LOG = function.getTableParameterList()
							.getTable("ET_LOG");
					String msg = "";
					JCO.ParameterList output = function
							.getExportParameterList();

					output.getValue("EV_MSG");

					System.out.println(output.getValue("EV_SUBRC"));
					if (function.getExportParameterList().getString("EV_SUBRC")
							.equals("0")) {
						if (type == 4) {
							String sql = "update sale_prod_line set sap_no='"
									+ iv_vbeln + "'" + " where prod_id="
									+ prod_id + " and line_type=4 ";
							this.getDataCentre().update(sql);

							sql = " insert into sale_prod_sap "
									+ " select prod_no,prod_id,pi_no,pi_id, qty,price,erp_code,cust_spec,  "
									+ " rownum+(select nvl(max(seq),0) from sale_prod_sap  where prod_id="
									+ prod_id
									+ " ) seq, "
									+ "  currency_code,deliver_date, "
									+ " inspection_batchno iv_vbeln,0 prod_line_id "
									+ " from (select m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty qty, "
									+ " t.price,n.erp_code,n.cust_spec,c.brand_name,    "
									+ " case when m.sale_ent_type=2 then '1300' else '1391' end store_loc,  "
									+ " case when m.sale_ent_type=2 then '1130' else '1100' end plant,  "
									+ " rownum +12  seq,m.currency_code,n.deliver_date ,m.inspection_batchno  "
									+ " from sale_prod_header m,sale_prod_h_line c , sale_prod_line n ,sale_prod_package t   "
									+ " where m.prod_id=n.prod_id   "
									+ " and m.prod_id=c.prod_id   "
									+ " and n.prod_h_id=c.prod_h_id   "
									+ " and m.prod_id=t.prod_id      "
									+ " and t.pack_qty>0       "
									+ " and m.prod_id="
									+ prod_id
									+ " and nvl(n.line_type,0)=4  "
									+ " group by m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty ,m.inspection_batchno,  "
									+ " t.price,n.erp_code,n.cust_spec,c.brand_name,c.CUST_ITEM_NAME,n.deliver_date,   "
									+ " m.sale_ent_type	,m.currency_code,rownum   "
									+ " order by deliver_date  ) where   rownum=1   ";
							this.getDataCentre().execute(sql);

						}
						if (type == 3 || type == 5) {
							String sql = "update sale_prod_m_header set is_sap=2 "
									+ " where prod_m_id=" + prod_id;
							this.getDataCentre().update(sql);

							for (int i = 0; i < vcqty.size(); i++) {
								Hashtable ht = (Hashtable) vcqty.elementAt(i);

								int seq = Integer.parseInt((String) ht
										.get("seq"));
								String qty = (String) ht.get("qty");

								sql = "update sale_prod_sap set qty=" + qty
										+ " where prod_id=" + prod_id
										+ " and seq=" + seq;
								this.getDataCentre().update(sql);

							}

						}
					} else {
						for (int m = 0; m < ET_LOG.getNumRows(); m++) {
							ET_LOG.setRow(m);
							msg = msg + ET_LOG.getString("MESSAGE") + ";\n";
							System.out.println(msg);

						}
						throw new IllegalLogicException(msg);
					}

				}

			} catch (Exception ex) {
				// this.getDataCentre().commit();
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}
	}

	*//**
	 * 判断物料编码在 1300或者1500组织是否存在
	 * *//*
	public int getZRFC_SCM_READ_MM03_SAP(String vkorg, String item_code)
			throws SinocpcException {
		int count = 0;
		String sql = "";

		if (this.db_connect(SCM_MM03) == 2) {
			// if(1==1)throw new IllegalDataException(vkorg+";"+item_code);
			JCO.Function function = null;
			JCO.Table ztmtrack = null;
			try {

				getConnection();
				function = createFunction(SCM_MM03); // 取物料数据表

				*//**
				 *输入要读取物料号码
				 * *//*

				JCO.Structure ip_vkorg = function.getImportParameterList()
						.getStructure("IS_VKORG"); // 销售组织+分销渠道输入条件
				ip_vkorg.setValue(vkorg, "VKORG");// 销售组织
				ip_vkorg.setValue("", "VTWEG");// 分销渠道
				JCO.ParameterList input = function.getImportParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
				input.setValue("", "IV_LGORT");// 库存地点
				input.setValue("", "IV_MAXRECORDS");// 限制列表的长度

				JCO.ParameterList list = function.getTableParameterList();
				// 物料输入表
				JCO.Table it_matnr = list.getTable("IT_MATNR"); // 是一个内表。
				it_matnr.appendRow();
				it_matnr.setRow(0);
				it_matnr.setValue("I", "SIGN");
				it_matnr.setValue("EQ", "OPTION");
				it_matnr.setValue(item_code, "LOW");
				it_matnr.setValue("", "HIGH");

				// //工厂输入表
				// JCO.Table it_werks = list.getTable("IT_WERKS"); // 是一个内表。
				// it_werks.appendRow();
				// it_werks.setRow(0);
				// it_werks.setValue("I","SIGN");
				// it_werks.setValue("EQ","OPTION");
				// it_werks.setValue("1100","LOW");
				// it_werks.setValue("", "HIGH");

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}
				mConnection.execute(function);
				ztmtrack = list.getTable("ET_OUTPUT1"); // 是一个内表。
				System.out.println(ztmtrack.getNumRows());
				if (ztmtrack.getNumRows() > 0) {
					count = 1;
				}

			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());
			} finally {

				if (mConnection != null) {
					mConnection.disconnect();
				}

			}

		}
		return count;
	}

	*//**
	 *创建到款凭证 F-22
	 * *//*

	public void ZIF_OMS_ACC_DOCUMENT_POST_F_221(Hashtable ht, Vector vc1,
			Vector vc2, String ip_bldat) throws SinocpcException {

		if (this.db_connect(SCM_F22) == 2) {

			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_F22); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_F22 + "在sap中没有发现");
				}

				// 表头
				JCO.Structure is_documentheader = function
						.getImportParameterList().getStructure(
								"IS_DOCUMENTHEADER");
				is_documentheader.setValue((String) ht.get("other_no"),
						"HEADER_TXT");// 抬头-资金单号
				is_documentheader.setValue("1130", "COMP_CODE");// 组织
				is_documentheader.setValue((String) ht.get("doc_date"),
						"DOC_DATE");// 凭证中的凭证日期
				is_documentheader.setValue(ip_bldat, "PSTNG_DATE");// 凭证中的过帐日期
				is_documentheader.setValue("", "FISC_YEAR");// 会计年度
				is_documentheader.setValue("", "FIS_PERIOD");// 会计期间

				// 更改参数
				JCO.Structure is_obj_created_info = function
						.getImportParameterList().getStructure(
								"IS_OBJ_CREATED_INFO");
				is_obj_created_info.setValue("OMS", "SOURCE_SYS");// 源系统
				is_obj_created_info.setValue((String) ht.get("funds_no"),
						"OBJ_TYP");// 对象类型
				is_obj_created_info.setValue((String) ht.get("funds_no"),
						"OBJ_KEY_EXT");// 对象关键字
				is_obj_created_info.setValue(this.getUserBean().UserId,
						"CREATED_BY_EXT");// 创建对象的人员名称

				// 总帐科目项
				JCO.ParameterList list = function.getTableParameterList();
				JCO.Table it_accountgl = list.getTable("IT_ACCOUNTGL"); // 是一个内表。

				it_accountgl.appendRow();
				it_accountgl.setRow(1);

				it_accountgl.setValue("0000000001", "ITEMNO_ACC");// 会计凭证行项目编号
				it_accountgl.setValue("1002030302", "GL_ACCOUNT");// 总账科目
				it_accountgl.setValue("2", "ITEM_TEXT");// 项目文本
				it_accountgl.setValue("DR", "DOC_TYPE");// 凭证类型
				it_accountgl.setValue("1130", "COMP_CODE");// 公司代码
				it_accountgl.setValue("K100", "BUS_AREA");// 业务范围
				it_accountgl.setValue("PI-1211", "ALLOC_NMBR");// 分配号--PI号

				// 客户项目
				JCO.Table it_accountreceivable = list
						.getTable("IT_ACCOUNTRECEIVABLE"); // 是一个内表。

				it_accountreceivable.appendRow();
				it_accountreceivable.setRow(1);

				it_accountreceivable.setValue("0000000004", "ITEMNO_ACC");// 会计凭证行项目编号
				it_accountreceivable.setValue("500645", "CUSTOMER");// 客户编号
				it_accountreceivable.setValue("1130", "COMP_CODE");// 公司代码
				it_accountreceivable.setValue("20121011", "BLINE_DATE");// 到期日计算的基限日期
				it_accountreceivable.setValue("PI-1211", "ALLOC_NMBR");// 分配号--PI号

				// 货币项目
				JCO.Table IT_CURRENCYAMOUNT = list
						.getTable("IT_CURRENCYAMOUNT"); // 是一个内表。

				IT_CURRENCYAMOUNT.appendRow();
				IT_CURRENCYAMOUNT.setRow(1);

				IT_CURRENCYAMOUNT.setValue("0000000001", "ITEMNO_ACC");// 会计凭证行项目编号
				IT_CURRENCYAMOUNT.setValue("USD", "CURRENCY");// 货币码
				IT_CURRENCYAMOUNT.setValue("300", "AMT_DOCCUR");// 凭证货币金额

				// 会计凭证扩展结构2：自定义
				JCO.Table it_zextension2 = list.getTable("IT_ZEXTENSION2"); // 是一个内表。
				it_zextension2.appendRow();
				it_zextension2.setRow(1);

				it_zextension2.setValue("0000000001", "POSNR");// 会计凭证行项目编号
				it_zextension2.setValue("40", "BSCHL");// 记帐代码
				it_zextension2.setValue("", "UMSKZ");// 特殊总帐标识
				it_zextension2.setValue("81011614703004045", "ZZ01");// 银行账号
				it_zextension2.setValue("A1", "ZZ02");// 现金流代码

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);
				System.out.println(IT_CURRENCYAMOUNT);

				// 返回参数
				JCO.Table et_return = function.getTableParameterList()
						.getTable("ET_RETURN");

				// 导出参数
				JCO.ParameterList output = function.getExportParameterList();
				String msg = "";

				System.out.println(output.getString("EV_SUBRC"));

				if (output.getString("EV_SUBRC").equals("0")) {
					System.out.println(output.getString("EV_BELNR"));
				} else {
					for (int m = 0; m < et_return.getNumRows(); m++) {
						et_return.setRow(m);
						msg = msg + et_return.getString("MESSAGE") + ";";
					}
					System.out.println(msg);

				}

			} catch (Exception ex) {
				this.getDataCentre().commit();
				ex.printStackTrace();
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}

		}
	}

	*//**
	 * 到款凭证单冲销
	 * *//*
	public void ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CXA(String iv_bukrs,
			String iv_belnr, int iv_gjahr, String iv_budat, int funds_id,
			String funds_no, int sap_id, String funds_m_no, int type,
			String iv_stgrd, int temp_type) throws SinocpcException {
		String sql = "";
		if (this.db_connect(F22_OFF) == 2) {

			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(F22_OFF); // 取物料数据表
				if (function == null) {
					System.out.println(F22_OFF + "在sap中没有发现");
				}

				JCO.ParameterList input = function.getImportParameterList(); // 获取import抬头结构

				input.setValue(iv_bukrs, "IV_BUKRS");// 公司代码
				input.setValue(iv_belnr, "IV_BELNR");// 财务凭证编号
				input.setValue(iv_gjahr, "IV_GJAHR");// 会计年度
				input.setValue(iv_stgrd, "IV_STGRD");// 冲销原因01,02
				input.setValue("", "IV_BUDAT");// 凭证记帐日期
				input.setValue("", "IV_MONAT");// 会计期间
				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}
				mConnection.execute(function);

				JCO.Table ET_MESSAGE = function.getTableParameterList()
						.getTable("ET_MESSAGE");
				JCO.ParameterList output = function.getExportParameterList();
				String msg = "";

				if (output.getString("EV_SUBRC").equals("0")) {
					if (type == 1) {
						sql = "update fin_funds_header set erp_stat=1 "
								+ ",erp_sap_stat=1 " + ",sap_no=sap_no||','||'"
								+ output.getString("EV_BELNR") + "'"
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);

						sql = " update fin_funds_allo_header set sap_erp_stat=0 "
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);

						sql = " update fin_funds_allo_line set sap_erp_stat=0 "
								+ " where allo_id in(select allo_id from fin_funds_allo_header"
								+ " where funds_id=" + funds_id + ")";
						this.getDataCentre().update(sql);

						sql = " update fin_funds_sap set fin_stat=2,usable=1"
								+ " where funds_id=" + funds_id
								+ " and sap_id=" + sap_id;
						this.getDataCentre().update(sql);

						sql = "update fin_funds_invoice_header set sap_erp_stat=0 "
								+ " where   funds_id=" + funds_id;
						this.getDataCentre().update(sql);

						this.infin_sap(funds_id, funds_no, output
								.getString("EV_BELNR"), iv_budat, "被冲销凭证:"
								+ iv_belnr, 2, 5, 2, funds_m_no, iv_bukrs, 1,
								temp_type);
					}
					if (type == 2) {
						sql = "update Bill_Invoice_Header set Is_Erp_Process=1 "
								+ " where invoice_id=" + funds_id;
						this.getDataCentre().update(sql);

						sql = "update Bill_Invoice_line set sap_no=sap_no||',"
								+ output.getString("EV_BELNR") + "'"
								+ " where invoice_id=" + funds_id;
						this.getDataCentre().update(sql);

						this.infin_sap(funds_id, funds_no, output
								.getString("EV_BELNR"), iv_budat, "被冲销凭证:"
								+ iv_belnr, 2, 5, 2, funds_m_no, iv_bukrs, 1,
								temp_type);

					}
				} else {
					if (iv_stgrd.equals("01")) {
						if (type == 1) {
							this.ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CXB(iv_bukrs,
									iv_belnr, iv_gjahr, iv_budat, funds_id,
									funds_no, sap_id, funds_m_no);
						} else if (type == 2) {
							this.ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CXA(iv_bukrs,
									iv_belnr, iv_gjahr, iv_budat, funds_id, "",
									0, "", 2, "02", temp_type);
						}
					} else {
						for (int m = 0; m < ET_MESSAGE.getNumRows(); m++) {
							ET_MESSAGE.setRow(m);
							msg = msg + ET_MESSAGE.getString("MESSAGE") + ";";
						}
						throw new IllegalLogicException(msg);
					}

				}

			} catch (Exception ex) {
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}
	}

	*//**
	 * 到款凭证单冲销
	 * *//*
	public void ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CXB(String iv_bukrs,
			String iv_belnr, int iv_gjahr, String iv_budat, int funds_id,
			String funds_no, int sap_id, String funds_m_no)
			throws SinocpcException {
		String sql = "";
		if (this.db_connect(F22_OFF) == 2) {
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(F22_OFF); // 取物料数据表
				if (function == null) {
					System.out.println(F22_OFF + "在sap中没有发现");
				}

				JCO.ParameterList input = function.getImportParameterList(); // 获取import抬头结构

				input.setValue(iv_bukrs, "IV_BUKRS");// 公司代码
				input.setValue(iv_belnr, "IV_BELNR");// 财务凭证编号
				input.setValue(iv_gjahr, "IV_GJAHR");// 会计年度
				input.setValue("02", "IV_STGRD");// 冲销原因01,02
				input.setValue(iv_budat, "IV_BUDAT");// 凭证记帐日期
				input.setValue("", "IV_MONAT");// 会计期间
				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}
				mConnection.execute(function);

				JCO.Table ET_MESSAGE = function.getTableParameterList()
						.getTable("ET_MESSAGE");
				String msg = "";

				JCO.ParameterList output = function.getExportParameterList();

				if (output.getString("EV_SUBRC").equals("0")) {

					sql = "update fin_funds_header set erp_stat=1 "
							+ ",erp_sap_stat=1 " + " where funds_id="
							+ funds_id;
					this.getDataCentre().update(sql);

					sql = " update fin_funds_allo_header set sap_erp_stat=0 "
							+ " where funds_id=" + funds_id;
					this.getDataCentre().update(sql);

					sql = " update fin_funds_allo_line set sap_erp_stat=0 "
							+ " where allo_id in(select allo_id from fin_funds_allo_header"
							+ " where funds_id=" + funds_id + ")";
					this.getDataCentre().update(sql);

					sql = " update fin_funds_sap set fin_stat=2 "
							+ " where funds_id=" + funds_id + " and sap_id="
							+ sap_id;
					this.getDataCentre().update(sql);

					sql = "update fin_funds_invoice_header set sap_erp_stat=0 "
							+ " where   funds_id=" + funds_id;
					this.getDataCentre().update(sql);

					this.infin_sap(funds_id, funds_no, output
							.getString("EV_BELNR"), iv_budat, "冲销凭证:"
							+ iv_belnr, 2, 5, 2, funds_m_no, iv_bukrs, 1, 2);
				} else {
					for (int m = 0; m < ET_MESSAGE.getNumRows(); m++) {
						ET_MESSAGE.setRow(m);
						msg = msg + ET_MESSAGE.getString("MESSAGE") + ";";
					}
					throw new IllegalLogicException(msg);
				}

			} catch (Exception ex) {
				// this.getDataCentre().commit();
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}
	}

	public void dofinfunds_Header(int funds_id, String ip_bldat)
			throws SinocpcException {
		Hashtable hth;
		Vector vcline;
		String sql = "select a.*,case when return_ent_type=1 then '宁波组织' else '香港组织' end zhuzi,a6.sap_zuzhi comp_code"
				+ " from fin_funds_header a ,sap_orggckcdz a6 "
				+ " where  confirm_stat=2 and a.return_ent_type=a6.sale_ent_type "
				+ " and a.funds_id=" + funds_id;
		Hashtable ht = this.getDataCentre().oneRowSelect(sql);
		if (ht != null) {
			int return_ent_type = Integer.parseInt((String) ht
					.get("return_ent_type"));// 贸易组织1：宁波 2：香港
			String zhuzi = (String) ht.get("zhuzi");
			String currency_code = (String) ht.get("currency_code");
			int cust_id = Integer.parseInt((String) ht.get("cust_id"));
			String sap_code = "";
			if (cust_id > 0) {
				sql = "select sap_code from customer where sap_code is not null and cust_id="
						+ cust_id;
				Hashtable htcust = this.getDataCentre().oneRowSelect(sql);
				if (htcust != null) {
					sap_code = "'" + (String) htcust.get("sap_code") + "-'";
				} else {
					throw new IllegalLogicException("SAP客户编码不存在,请维护!");
				}

			}
			sql = "select count(*)\n" + "  from (select sp.sale_ent_type\n"
					+ "          from fin_funds_allo_line   fa,\n"
					+ "               sale_pi_header        sp,\n"
					+ "               fin_funds_allo_header fh\n"
					+ "         where fh.funds_id ="
					+ funds_id
					+ "           and fh.allo_id = fa.allo_id\n"
					+ "           and fa.pi_id = sp.pi_id\n"
					+ "           and fh.stat = 5\n"
					+ "           and fh.is_byhand <> 2\n"
					+ "           and fa.sap_erp_stat<>2\n"
					+ "        union\n"
					+ "        select fh.trade_type\n"
					+ "          from fin_funds_allo_header fh\n"
					+ "         where fh.is_byhand = 2\n"
					+ "           and fh.stat = 5\n"
					+ "           and fh.sap_erp_stat<>2\n"
					+ "           and fh.funds_id ="
					+ funds_id
					+ "        union\n"
					+ "        select m.trade_type\n"
					+ "          from fin_funds_invoice_header m, fin_funds_invoice_line n\n"
					+ "         where m.allo_id = n.allo_id\n"
					+ "           and m.stat = 5\n"
					+ "           and m.sap_erp_stat<>2\n"
					+ "           and m.funds_id ="
					+ funds_id
					+ ")"
					+ " where sale_ent_type<>" + return_ent_type;
			// 判断如果到款单组织是选择的香港 则PI是香港直营的 不算是多组织的
			if (return_ent_type == 2) {
				sql += " and sale_ent_type<>3";

			}

			int count2 = this.getDataCentre().intSelect(sql);// 查出当前到款单分配的组织是否有多个
			String pinos = "";
			if (count2 > 0) {
				sql = "select wm_concat(distinct pi_no) pi_no\n"
						+ "  from (select fa.pi_no, sale_ent_type\n"
						+ "          from fin_funds_allo_line   fa,\n"
						+ "               sale_pi_header        sp,\n"
						+ "               fin_funds_allo_header fh\n"
						+ "         where fh.funds_id ="
						+ funds_id
						+ "           and fh.allo_id = fa.allo_id\n"
						+ "           and fa.pi_id = sp.pi_id\n"
						+ "           and fh.stat = 5\n"
						+ "           and fh.is_byhand <> 2\n"
						+ "           and fa.sap_erp_stat <> 2\n"
						+ "        union\n"
						+ "        select fh.pi_no, trade_type\n"
						+ "          from fin_funds_allo_header fh\n"
						+ "         where fh.is_byhand = 2\n"
						+ "           and fh.stat = 5\n"
						+ "           and fh.sap_erp_stat <> 2\n"
						+ "           and fh.funds_id ="
						+ funds_id
						+ "        union\n"
						+ "        select n.pi_no, trade_type\n"
						+ "          from fin_funds_invoice_header m, fin_funds_invoice_line n\n"
						+ "         where m.allo_id = n.allo_id\n"
						+ "           and m.stat = 5\n"
						+ "           and m.sap_erp_stat <> 2\n"
						+ "           and m.funds_id ="
						+ funds_id
						+ ")\n"
						+ " where sale_ent_type <>" + return_ent_type;
				pinos = "'" + this.getDataCentre().strSelect(sql) + "'";
			}

			int erp_sap_stat = Integer
					.parseInt((String) ht.get("erp_sap_stat"));
			int funds_type = Integer.parseInt((String) ht.get("funds_type"));// 到款类型
																				// 1：TT
																				// 2：LC

			int tt_type = Integer.parseInt((String) ht.get("tt_type"));// TT到款类型
																		// 1:TT-现金、2:TT-转货款
			String funds_no = (String) ht.get("funds_no");
			double amtdeduct;// 费用
			String amt_deduct = (String) ht.get("amt_deduct");
			amtdeduct = new Double(amt_deduct).doubleValue();

			double lcinterest;// 利息
			String lc_interest = (String) ht.get("lc_interest");
			lcinterest = new Double(lc_interest).doubleValue();

			double amt;// 实收金额
			String amt1 = (String) ht.get("amt");
			amt = new Double(amt1).doubleValue();

			double factamt;// 实际到款总额
			String fact_amt = (String) ht.get("fact_amt");
			factamt = new Double(fact_amt).doubleValue();

			double allocatedamt;// 已经分配总额
			String allocated_amt = (String) ht.get("allocated_amt");
			allocatedamt = new Double(allocated_amt).doubleValue();
			String comp_code = (String) ht.get("comp_code");

			// 取暂收客户
			if (currency_code.equals("CNY")) {
				sql = " select dictvalue from cpcdict where dictcode like '%Cust_Code2%'";
			} else {
				sql = " select dictvalue from cpcdict where dictcode like '%Cust_Code1%'";
			}
			String dictvalue = "'" + this.getDataCentre().strSelect(sql) + "'";

			sql = "select a.other_no,\n"
					+ "       to_char(Funds_Date, 'yyyymmdd') DOC_DATE,\n"
					+ "       a.funds_no,a.pzzs,\n"
					+ "       a.amt_deduct,\n"
					+ "       a.fact_amt,\n"
					+ "       a.lc_interest,\n"
					+ "       a.currency_code,'1130' comp_code,\n"
					+ "       a.sap_account,erp_sap_stat,erp_stat,\n"
					+ "       to_char(sysdate,'yyyymmddhh24miss')fundsno,\n"
					+ "       'SA'doc_type,a.hth item_text,\n"
					+ "       to_char(rongzi_dqdate,'yyyymmdd')rongzi_dqdate,case when a.tt_type=3 then 1 else\n"
					+ "       case when a.lc_cash_type=1 then 1 else 2 end end rongzitype\n"
					+ "  from fin_funds_header a\n" + " where  a.funds_id ="
					+ funds_id;
			hth = this.getDataCentre().oneRowSelect(sql);

			// 传之前判断确实有需要传的金额再传
			sql = " select sum(qty)\n" + "  from (select count(1) qty\n"
					+ "          from fin_funds_allo_header m,\n"
					+ "               fin_funds_allo_line   n,\n"
					+ "               base_contract         k,\n"
					+ "               fin_funds_header      l\n"
					+ "         where m.allo_id = n.allo_id\n"
					+ "           and m.org_id = k.org_id\n"
					+ "           and m.funds_id = l.funds_id\n"
					+ "           and nvl(is_byhand, 0) <> 2\n"
					+ "           and m.funds_id ="
					+ funds_id
					+ "           and m.stat = 5\n"
					+ "           and nvl(n.sap_erp_stat, 0) <> 2\n"
					+ "           and nvl(n.allo_amt, 0) > 0\n"
					+ "        union all\n"
					+ "        select count(1)\n"
					+ "          from fin_funds_allo_header m, base_contract k, fin_funds_header l\n"
					+ "         where m.org_id = k.org_id\n"
					+ "           and m.funds_id = l.funds_id\n"
					+ "           and m.funds_id ="
					+ funds_id
					+ "           and nvl(is_byhand, 0) = 2\n"
					+ "           and m.stat = 5\n"
					+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
					+ "           and nvl(m.total_allo_amt, 0) > 0\n"
					+ "        union all\n"
					+ "        select count(1)\n"
					+ "          from fin_funds_invoice_header m,\n"
					+ "               fin_funds_invoice_line   n,\n"
					+ "               fin_funds_header         l,\n"
					+ "               base_contract            k\n"
					+ "         where m.org_id = k.org_id\n"
					+ "           and m.ALLO_ID = n.ALLO_ID\n"
					+ "           and m.funds_id = l.funds_id\n"
					+ "           and l.funds_id ="
					+ funds_id
					+ "           AND m.stat = 5\n"
					+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
					+ "         group by l.cust_id, n.pi_no, l.currency_code)";
			int count10 = this.getDataCentre().intSelect(sql);

			// TT到款
			if (funds_type == 1 && tt_type == 1) {
				if (erp_sap_stat < 10) {

					*//**
					 * 1 到款金额大于0 分配金额等于0 引ERP状态等于1 40 借 银行 1000 40 借 费用 200 15 贷
					 * 暂收客户(指定) 1200
					 * *//*
					if (factamt > 0 && allocatedamt == 0 && erp_sap_stat == 1) {

						// 传 erp_sap_stat==3

						sql = "select a.*, rownum seq\n"
								+ "  from (select a.sap_account,\n"
								+ "               '暂收款' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               a.amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               'A1' ZZ02,\n"
								+ "               b.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               a.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'暂收款' item_text\n"
								+ "          from fin_funds_header a, bank b\n"
								+ "         where a.funds_id ="
								+ funds_id
								+ "           and a.bank_id = b.bank_id\n"
								+ "           and a.amt > 0\n"
								+ "        union all\n"
								+ "        select '6603010006' sap_account,\n"
								+ "               '手续费' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               a.amt_deduct amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               a.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'手续费' item_text\n"
								+ "          from fin_funds_header a\n"
								+ "         where a.funds_id ="
								+ funds_id
								+ "           and a.amt_deduct > 0\n"
								+ "        union all\n"
								+ "        select "
								+ dictvalue
								+ " cust_code,\n"
								+ "               '暂收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -a.fact_amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               a.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'暂收款' item_text\n"
								+ "          from fin_funds_header a\n"
								+ "         where a.funds_id ="
								+ funds_id
								+ "           and a.amt > 0) a";
						vcline = this.getDataCentre().multiRowSelect(sql);

						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 3, 3, 1, 0, 0, comp_code,
								2, "暂收款");

					}
					*//**
					 * 2 分配金额大于0 到款金额不等于分配金额 引ERP状态等于1 40 借 银行 1000 40 借 费用 200
					 * 15 贷 客户 800 15 贷 暂收(真实客户) 400
					 * *//*
					else if (factamt != allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 1 && count2 == 0 && count10 > 0) {

						sql = "\n"
								+ "select w1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               'A1' ZZ02,\n"
								+ "               a.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '收款' item_text,a.sap_account\n"
								+ "          from fin_funds_header b, bank a\n"
								+ "         where b.bank_id = a.bank_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "  union all        select b.cust_id,\n"
								+ "           '手续费' ALLOC_NMBR,\n"
								+ "           1 linetype,\n"
								+ "           amt_deduct amt,\n"
								+ "           '40' BSCHL,\n"
								+ "           '' ZZ02,\n"
								+ "           '' ZZ01,\n"
								+ "           '' UMSKZ,\n"
								+ "           b.currency_code,\n"
								+ "           'SA' DOC_TYPE,\n"
								+ "           '1130' COMP_CODE,\n"
								+ "           '手续费' item_text,'6603010006'sap_account\n"
								+ "           from fin_funds_header b\n"
								+ "           where b.funds_id ="
								+ funds_id
								+ "           and b.amt_deduct > 0\n"
								+ "        union all\n"
								+ "        select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "                union all\n"
								+ "                select b.cust_id,\n"
								+ "                       '暂收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       - (b.fact_amt - b.allocated_amt) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       b.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,'暂收款' item_text\n"
								+ "                  from fin_funds_header b\n"
								+ "                 where b.funds_id ="
								+ funds_id
								+ "\n"
								+ "                   and b.amt > 0) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id) w1";
						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 3, 2, 1, 0, 0, comp_code,
								2, "分配金额大于0   到款金额不等于分配金额  引ERP状态等于1");

					}
					*//**
					 * 3 分配金额大于0 到款金额等于分配金额 引ERP状态等于1 40 借 银行 1000 40 借 费用 200
					 * 15 贷 客户 800 15 贷 客户 400
					 * *//*
					else if (factamt == allocatedamt && erp_sap_stat == 1
							&& allocatedamt > 0 && count2 == 0 && count10 > 0) {

						sql = "select w1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               'A1' ZZ02,\n"
								+ "               a.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '收款' item_text,a.sap_account\n"
								+ "          from fin_funds_header b, bank a\n"
								+ "         where b.bank_id = a.bank_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "           union all\n"
								+ "           select b.cust_id,\n"
								+ "           '手续费' ALLOC_NMBR,\n"
								+ "           1 linetype,\n"
								+ "           amt_deduct amt,\n"
								+ "           '40' BSCHL,\n"
								+ "           '' ZZ02,\n"
								+ "           '' ZZ01,\n"
								+ "           '' UMSKZ,\n"
								+ "           b.currency_code,\n"
								+ "           'SA' DOC_TYPE,\n"
								+ "           '1130' COMP_CODE,\n"
								+ "           '手续费' item_text,'6603010006' sap_account\n"
								+ "           from fin_funds_header b\n"
								+ "           where b.funds_id ="
								+ funds_id
								+ "           and b.amt_deduct > 0\n"
								+ "        union all\n"
								+ "        select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 1, 0, 0, comp_code,
								2, "分配金额大于0   到款金额等于分配金额  引ERP状态等于1");

					}
					*//**
					 * 4 分配金额大于0 到款金额不等于分配金额 引ERP状态等于2 取真实客户 引暂收 40 借 暂收(真实客户)
					 * 1000 15 贷 客户 800 15 贷 暂收(真实客户) 200
					 * *//*
					else if (factamt != allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 2 && count2 == 0 && count10 > 0) {

						sql = "select a1.*, a2.sap_code sap_account, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '暂收款确认' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               fact_amt -\n"
								+ "               (select nvl(sum(amt),0)\n"
								+ "                  from (select n.allo_amt amt\n"
								+ "                          from fin_funds_allo_header m,\n"
								+ "                               fin_funds_allo_line   n,\n"
								+ "                               fin_funds_header      l\n"
								+ "                         where m.allo_id = n.allo_id\n"
								+ "                           and m.funds_id = l.funds_id\n"
								+ "                           and nvl(is_byhand, 0) <> 2\n"
								+ "                           and m.funds_id ="
								+ funds_id
								+ "                           and m.stat = 5\n"
								+ "                           and nvl(n.sap_erp_stat, 0) = 2\n"
								+ "                           and nvl(n.allo_amt, 0) > 0\n"
								+ "                        union all\n"
								+ "                        select m.total_allo_amt amt\n"
								+ "                          from fin_funds_allo_header m, fin_funds_header l\n"
								+ "                         where m.funds_id = l.funds_id\n"
								+ "                           and m.funds_id ="
								+ funds_id
								+ "                           and nvl(is_byhand, 0) = 2\n"
								+ "                           and m.stat = 5\n"
								+ "                           and nvl(m.sap_erp_stat, 0) = 2\n"
								+ "                           and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                        union all\n"
								+ "                        select n.INVOICE_CHECK_AMT amt\n"
								+ "                          from fin_funds_invoice_header m,\n"
								+ "                               fin_funds_invoice_line   n,\n"
								+ "                               fin_funds_header         l\n"
								+ "                         where m.ALLO_ID = n.ALLO_ID\n"
								+ "                           and m.funds_id = l.funds_id\n"
								+ "                           and l.funds_id ="
								+ funds_id
								+ "                           AND m.stat = 5\n"
								+ "                           and nvl(m.sap_erp_stat, 0) = 2))amt,\n"
								+ "               '05' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'暂收款确认' item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -n.allo_amt amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,n.pi_no item_text\n"
								+ "          from fin_funds_allo_header m,\n"
								+ "               fin_funds_allo_line   n,\n"
								+ "               base_contract         k,\n"
								+ "               fin_funds_header      l\n"
								+ "         where m.allo_id = n.allo_id\n"
								+ "           and m.org_id = k.org_id\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and nvl(is_byhand, 0) <> 2\n"
								+ "           and m.funds_id ="
								+ funds_id
								+ "           and m.stat = 5\n"
								+ "           and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "           and nvl(n.allo_amt, 0) > 0\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -m.total_allo_amt amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,m.pi_no item_text\n"
								+ "          from fin_funds_allo_header m, base_contract k, fin_funds_header l\n"
								+ "         where m.org_id = k.org_id\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and m.funds_id ="
								+ funds_id
								+ "           and nvl(is_byhand, 0) = 2\n"
								+ "           and m.stat = 5\n"
								+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "           and nvl(m.total_allo_amt, 0) > 0\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,n.pi_no item_text\n"
								+ "          from fin_funds_invoice_header m,\n"
								+ "               fin_funds_invoice_line   n,\n"
								+ "               fin_funds_header         l,\n"
								+ "               base_contract            k\n"
								+ "         where m.org_id = k.org_id\n"
								+ "           and m.ALLO_ID = n.ALLO_ID\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and l.funds_id ="
								+ funds_id
								+ "           AND m.stat = 5\n"
								+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "         group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "        union all\n"
								+ "        select b.cust_id,\n"
								+ "               '暂收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               - (fact_amt - b.allocated_amt),\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'暂收款' item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "           and b.allocated_amt <> b.fact_amt\n"
								+ "           and b.fact_amt > b.allocated_amt) a1,\n"
								+ "       customer a2\n"
								+ " where a1.cust_id = a2.cust_id";
						vcline = this.getDataCentre().multiRowSelect(sql);

						this
								.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
										ip_bldat, funds_id, 3, 2, 1, 0, 0,
										comp_code, 2,
										"分配金额大于0   到款金额不等于分配金额  引ERP状态等于2 取真实客户 引暂收");

					}
					*//**
					 * 5 分配金额大于0 到款金额等于分配金额 引ERP状态等于2 取真实客户 引暂收 40 借 暂收(真实客户)
					 * 1000 15 贷 客户 800 15 贷 客户 200
					 * *//*
					else if (factamt == allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 2 && count2 == 0 && count10 > 0) {

						sql = "select a1.*, a2.sap_code sap_account, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '暂收款确认' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               fact_amt -\n"
								+ "               (select nvl(sum(amt),0)\n"
								+ "                  from (select n.allo_amt amt\n"
								+ "                          from fin_funds_allo_header m,\n"
								+ "                               fin_funds_allo_line   n,\n"
								+ "                               fin_funds_header      l\n"
								+ "                         where m.allo_id = n.allo_id\n"
								+ "                           and m.funds_id = l.funds_id\n"
								+ "                           and nvl(is_byhand, 0) <> 2\n"
								+ "                           and m.funds_id ="
								+ funds_id
								+ "                           and m.stat = 5\n"
								+ "                           and nvl(n.sap_erp_stat, 0) = 2\n"
								+ "                           and nvl(n.allo_amt, 0) > 0\n"
								+ "                        union all\n"
								+ "                        select m.total_allo_amt amt\n"
								+ "                          from fin_funds_allo_header m, fin_funds_header l\n"
								+ "                         where m.funds_id = l.funds_id\n"
								+ "                           and m.funds_id ="
								+ funds_id
								+ "                           and nvl(is_byhand, 0) = 2\n"
								+ "                           and m.stat = 5\n"
								+ "                           and nvl(m.sap_erp_stat, 0) = 2\n"
								+ "                           and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                        union all\n"
								+ "                        select n.INVOICE_CHECK_AMT amt\n"
								+ "                          from fin_funds_invoice_header m,\n"
								+ "                               fin_funds_invoice_line   n,\n"
								+ "                               fin_funds_header         l\n"
								+ "                         where m.ALLO_ID = n.ALLO_ID\n"
								+ "                           and m.funds_id = l.funds_id\n"
								+ "                           and l.funds_id ="
								+ funds_id
								+ "                           AND m.stat = 5\n"
								+ "                           and nvl(m.sap_erp_stat, 0) = 2))amt,\n"
								+ "               '05' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'暂收款确认' item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -n.allo_amt amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,n.pi_no item_text\n"
								+ "          from fin_funds_allo_header m,\n"
								+ "               fin_funds_allo_line   n,\n"
								+ "               base_contract         k,\n"
								+ "               fin_funds_header      l\n"
								+ "         where m.allo_id = n.allo_id\n"
								+ "           and m.org_id = k.org_id\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and nvl(is_byhand, 0) <> 2\n"
								+ "           and m.funds_id ="
								+ funds_id
								+ "           and m.stat = 5\n"
								+ "           and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "           and nvl(n.allo_amt, 0) > 0\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -m.total_allo_amt amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,m.pi_no item_text\n"
								+ "          from fin_funds_allo_header m, base_contract k, fin_funds_header l\n"
								+ "         where m.org_id = k.org_id\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and m.funds_id ="
								+ funds_id
								+ "           and nvl(is_byhand, 0) = 2\n"
								+ "           and m.stat = 5\n"
								+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "           and nvl(m.total_allo_amt, 0) > 0\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,n.pi_no item_text\n"
								+ "          from fin_funds_invoice_header m,\n"
								+ "               fin_funds_invoice_line   n,\n"
								+ "               fin_funds_header         l,\n"
								+ "               base_contract            k\n"
								+ "         where m.org_id = k.org_id\n"
								+ "           and m.ALLO_ID = n.ALLO_ID\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and l.funds_id ="
								+ funds_id
								+ "           AND m.stat = 5\n"
								+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "         group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "        union all\n"
								+ "        select b.cust_id,\n"
								+ "               '暂收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               - (fact_amt - b.allocated_amt),\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'暂收款' item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "           and b.allocated_amt <> b.fact_amt\n"
								+ "           and b.fact_amt > b.allocated_amt) a1,\n"
								+ "       customer a2\n"
								+ " where a1.cust_id = a2.cust_id";
						vcline = this.getDataCentre().multiRowSelect(sql);

						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 1, 0, 0, comp_code,
								2, "分配金额大于0   到款金额等于分配金额  引ERP状态等于2");

					}
					*//**
					 * 6 分配金额大于0 到款金额等于分配金额 引ERP状态等于3 取真实客户 引暂收 40 借 暂收(暂收客户)
					 * 1200 15 贷 客户 800 15 贷 客户 200
					 * *//*
					else if (factamt == allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 3 && count2 == 0 && count10 > 0) {
						// 传 erp_sap_stat==3

						sql = "select w1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '暂收款确认' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               fact_amt amt,\n"
								+ "               '05' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '暂收款确认' item_text,'1130' COMP_CODE,\n"
								+ dictvalue
								+ " sap_account\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union all\n"
								+ "        select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       n.pi_no item_text, '1130' COMP_CODE\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       m.pi_no item_text,'1130' COMP_CODE\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       n.pi_no item_text,'1130' COMP_CODE\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id) w1";
						vcline = this.getDataCentre().multiRowSelect(sql);

						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 1, 0, 0, comp_code,
								2, "分配金额大于0   到款金额等于分配金额  引ERP状态等于3");

					}
					*//**
					 * 7 分配金额大于0 到款金额不等于分配金额 引ERP状态等于3 取真实客户 引暂收 40 借 暂收(暂收客户)
					 * 1200 15 贷 客户 800 15 贷 暂收(真实客户) 400
					 * *//*
					else if (factamt != allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 3 && count2 == 0 && count10 > 0) {

						sql = "select w1.*,rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '暂收款确认' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               fact_amt amt,\n"
								+ "               '05' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '暂收款确认' item_text,"
								+ dictvalue
								+ " sap_account\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union all\n"
								+ "       select a1.*, a2.sap_code from("
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -n.allo_amt amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,n.pi_no item_text\n"
								+ "          from fin_funds_allo_header m,\n"
								+ "               fin_funds_allo_line   n,\n"
								+ "               base_contract         k,\n"
								+ "               fin_funds_header      l\n"
								+ "         where m.allo_id = n.allo_id\n"
								+ "           and m.org_id = k.org_id\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and nvl(is_byhand, 0) <> 2\n"
								+ "           and m.funds_id ="
								+ funds_id
								+ "           and m.stat = 5\n"
								+ "           and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "           and nvl(n.allo_amt, 0) > 0\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -m.total_allo_amt amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,m.pi_no item_text\n"
								+ "          from fin_funds_allo_header m, base_contract k, fin_funds_header l\n"
								+ "         where m.org_id = k.org_id\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and m.funds_id ="
								+ funds_id
								+ "           and nvl(is_byhand, 0) = 2\n"
								+ "           and m.stat = 5\n"
								+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "           and nvl(m.total_allo_amt, 0) > 0\n"
								+ "        union all\n"
								+ "        select l.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               l.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,n.pi_no item_text\n"
								+ "          from fin_funds_invoice_header m,\n"
								+ "               fin_funds_invoice_line   n,\n"
								+ "               fin_funds_header         l,\n"
								+ "               base_contract            k\n"
								+ "         where m.org_id = k.org_id\n"
								+ "           and m.ALLO_ID = n.ALLO_ID\n"
								+ "           and m.funds_id = l.funds_id\n"
								+ "           and l.funds_id ="
								+ funds_id
								+ "           AND m.stat = 5\n"
								+ "           and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "         group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "        union all\n"
								+ "        select b.cust_id,\n"
								+ "               '暂收款' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               - (fact_amt - b.allocated_amt),\n"
								+ "               '15' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,'暂收款' item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "           and b.allocated_amt <> b.fact_amt\n"
								+ "           and b.fact_amt > b.allocated_amt) a1,\n"
								+ "       customer a2\n"
								+ " where a1.cust_id = a2.cust_id) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);

						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 3, 2, 1, 0, 0, comp_code,
								2, "分配金额大于0   到款金额不等于分配金额  引ERP状态等于3");
					}
					*//**
					 *8 引到款 跨组织 直接分配完成 引erp_sap_stat==1 (凭证1) 40 银行 900 40 费用
					 * 100 15 客户 200 15 客户 300 15 1500 500 (凭证2) 25 1130 500 15
					 * 客户 500
					 * *//*
					else if (factamt == allocatedamt && erp_sap_stat == 1
							&& allocatedamt > 0 && count2 > 0 && count10 > 0) {

						sql = "select w1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               'A1' ZZ02,\n"
								+ "               a.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '收款' item_text,\n"
								+ "               a.sap_account\n"
								+ "          from fin_funds_header b, bank a\n"
								+ "         where b.bank_id = a.bank_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union all\n"
								+ "        select b.cust_id,\n"
								+ "               '手续费' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt_deduct amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '手续费' item_text,\n"
								+ "               '6603010006' sap_account\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt_deduct > 0\n"
								+ "        union all\n"
								+ "        select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type = sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               case when return_ent_type=1 then 2 else  3 end linetype,\n"
								+ "               nvl(sum(amt), 0) amt,\n"
								+ "               case when return_ent_type=1 then '15' else '35' end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ " item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1500'\n"
								+ "                 else\n"
								+ "                  '1130'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type\n"
								+ "\n" + "        ) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 1, 0, 0, comp_code,
								1, "跨组织-直接分配完成引erp_sap_stat==1");

						if (return_ent_type == 1) {
							comp_code = "1500";
						} else {
							comp_code = "1130";
						}

						sql = "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "                 case when return_ent_type=1 then 3 else 2 end linetype,\n"
								+ "               -nvl(sum(amt), 0) amt,\n"
								+ "               case when return_ent_type=1 then '25' else  '05' end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ " item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1130'\n"
								+ "                 else\n"
								+ "                  '1500'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 1, 0, 0, comp_code,
								2, "跨组织-直接分配完成引erp_sap_stat==1");

					}
					*//**
					 *9 引到款 跨组织 直接分配 但是未分配完成 引到款 (两个凭证) (凭证1) 40 银行 900 40 费用
					 * 100 15 客户 200 15 客户暂收 300 15 1500 500 (凭证2) 25 1130 500
					 * 15 客户 500
					 * *//*
					else if (factamt != allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 1 && count2 > 0 && count10 > 0) {

						sql = "select w1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               'A1' ZZ02,\n"
								+ "               a.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '收款' item_text,\n"
								+ "               a.sap_account\n"
								+ "          from fin_funds_header b, bank a\n"
								+ "         where b.bank_id = a.bank_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union all\n"
								+ "        select b.cust_id,\n"
								+ "               '手续费' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt_deduct amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '手续费' item_text,\n"
								+ "               '6603010006' sap_account\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt_deduct > 0\n"
								+ "        union all\n"
								+ "        select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and sp.pi_id = n.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and sp.sale_ent_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "                union all\n"
								+ "                select b.cust_id,\n"
								+ "                       '暂收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       - (b.fact_amt - b.allocated_amt) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       b.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       '暂收款' item_text\n"
								+ "                  from fin_funds_header b\n"
								+ "                 where b.funds_id ="
								+ funds_id
								+ "\n"
								+ "                   and b.amt > 0) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"

								+ "\n"
								+ "        select cust_id,\n"
								+ "               '收款' ALLOC_NMBR,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  2\n"
								+ "                 else\n"
								+ "                  3\n"
								+ "               end linetype,\n"
								+ "               nvl(sum(amt), 0) amt,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '15'\n"
								+ "                 else\n"
								+ "                  '35'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1500'\n"
								+ "                 else\n"
								+ "                  '1130'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 3, 2, 1, 0, 0, comp_code,
								1, "跨组织-直接分配但是未分配完成引erp_sap_stat==1");

						if (return_ent_type == 1) {
							comp_code = "1500";
						} else {
							comp_code = "1130";
						}

						sql = "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "                 case when return_ent_type=1 then 3 else 2 end linetype,\n"
								+ "               -nvl(sum(amt), 0) amt,\n"
								+ "               case when return_ent_type=1 then '25' else  '05' end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1130'\n"
								+ "                 else\n"
								+ "                  '1500'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 3, 2, 1, 0, 0, comp_code,
								2, "跨组织-直接分配但是未分配完成引erp_sap_stat==1");

					}

					*//**
					 * 10 分配金额大于0 到款金额不等于分配金额 引ERP状态等于2 取真实客户 引暂收 凭证(1) 05 借
					 * 暂收(真实客户) 1000 15 贷 客户 600 15 贷 暂收(真实客户) 200 15 1500 200
					 * 凭证(2) 25 1130 200 15 客户 200
					 * *//*
					else if (factamt != allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 2 && count2 > 0 && count10 > 0) {

						sql = "\n"
								+ "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select b.cust_id,\n"
								+ "                       '暂收款确认' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       fact_amt -\n"
								+ "                       (select nvl(sum(amt),0)\n"
								+ "                          from (select n.allo_amt amt\n"
								+ "                                  from fin_funds_allo_header m,\n"
								+ "                                       fin_funds_allo_line   n,\n"
								+ "                                       fin_funds_header      l\n"
								+ "                                 where m.allo_id = n.allo_id\n"
								+ "                                   and m.funds_id = l.funds_id\n"
								+ "                                   and nvl(is_byhand, 0) <> 2\n"
								+ "                                   and m.funds_id ="
								+ funds_id
								+ "                                   and m.stat = 5\n"
								+ "                                   and nvl(n.sap_erp_stat, 0) = 2\n"
								+ "                                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                                union all\n"
								+ "                                select m.total_allo_amt amt\n"
								+ "                                  from fin_funds_allo_header m,\n"
								+ "                                       fin_funds_header      l\n"
								+ "                                 where m.funds_id = l.funds_id\n"
								+ "                                   and m.funds_id ="
								+ funds_id
								+ "                                   and nvl(is_byhand, 0) = 2\n"
								+ "                                   and m.stat = 5\n"
								+ "                                   and nvl(m.sap_erp_stat, 0) = 2\n"
								+ "                                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                                union all\n"
								+ "                                select n.INVOICE_CHECK_AMT amt\n"
								+ "                                  from fin_funds_invoice_header m,\n"
								+ "                                       fin_funds_invoice_line   n,\n"
								+ "                                       fin_funds_header         l\n"
								+ "                                 where m.ALLO_ID = n.ALLO_ID\n"
								+ "                                   and m.funds_id = l.funds_id\n"
								+ "                                   and l.funds_id ="
								+ funds_id
								+ "                                   AND m.stat = 5\n"
								+ "                                   and nvl(m.sap_erp_stat, 0) = 2)) amt,\n"
								+ "                       '05' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       b.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       '暂收款确认' item_text\n"
								+ "                  from fin_funds_header b\n"
								+ "                 where b.funds_id ="
								+ funds_id
								+ "                   and b.amt > 0\n"
								+ "\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and sp.pi_id = n.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and sp.sale_ent_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "                union all\n"
								+ "                select b.cust_id,\n"
								+ "                       '暂收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       - (fact_amt - b.allocated_amt),\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       b.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       '暂收款' item_text\n"
								+ "                  from fin_funds_header b\n"
								+ "                 where b.funds_id ="
								+ funds_id
								+ "                   and b.amt > 0\n"
								+ "                   and b.allocated_amt <> b.fact_amt\n"
								+ "                   and b.fact_amt > b.allocated_amt) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  2\n"
								+ "                 else\n"
								+ "                  3\n"
								+ "               end linetype,\n"
								+ "               nvl(sum(amt), 0) amt,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '15'\n"
								+ "                 else\n"
								+ "                  '35'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1500'\n"
								+ "                 else\n"
								+ "                  '1130'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 3, 2, 1, 0, 0, comp_code,
								1, "跨组织-分配金额大于0到款金额不等于分配金额引ERP状态等于2 取真实客户 引暂收");

						if (return_ent_type == 1) {
							comp_code = "1500";
						} else {
							comp_code = "1130";
						}

						sql = "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "                 case when return_ent_type=1 then 3 else 2 end linetype,\n"
								+ "               -nvl(sum(amt), 0) amt,\n"
								+ "               case when return_ent_type=1 then '25' else  '05' end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1130'\n"
								+ "                 else\n"
								+ "                  '1500'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 3, 2, 1, 0, 0, comp_code,
								2,
								"跨组织-分配金额大于0 到款金额不等于分配金额  引ERP状态等于2 取真实客户 引暂收");

					}
					*//**
					 * 11 分配金额大于0 到款金额等于分配金额 引ERP状态等于2 取真实客户 引暂收 凭证(1) 40 借
					 * 暂收(真实客户) 1000 15 贷 客户 400 15 贷 1500 600 凭证(2) 25 1130 600
					 * 15 客户 600
					 * *//*
					else if (factamt == allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 2 && count2 > 0 && count10 > 0) {

						sql = "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select b.cust_id,\n"
								+ "                       '暂收款确认' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       fact_amt -\n"
								+ "                       (select nvl(sum(amt),0)\n"
								+ "                          from (select n.allo_amt amt\n"
								+ "                                  from fin_funds_allo_header m,\n"
								+ "                                       fin_funds_allo_line   n,\n"
								+ "                                       fin_funds_header      l\n"
								+ "                                 where m.allo_id = n.allo_id\n"
								+ "                                   and m.funds_id = l.funds_id\n"
								+ "                                   and nvl(is_byhand, 0) <> 2\n"
								+ "                                   and m.funds_id ="
								+ funds_id
								+ "                                   and m.stat = 5\n"
								+ "                                   and nvl(n.sap_erp_stat, 0) = 2\n"
								+ "                                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                                union all\n"
								+ "                                select m.total_allo_amt amt\n"
								+ "                                  from fin_funds_allo_header m,\n"
								+ "                                       fin_funds_header      l\n"
								+ "                                 where m.funds_id = l.funds_id\n"
								+ "                                   and m.funds_id ="
								+ funds_id
								+ "                                   and nvl(is_byhand, 0) = 2\n"
								+ "                                   and m.stat = 5\n"
								+ "                                   and nvl(m.sap_erp_stat, 0) = 2\n"
								+ "                                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                                union all\n"
								+ "                                select n.INVOICE_CHECK_AMT amt\n"
								+ "                                  from fin_funds_invoice_header m,\n"
								+ "                                       fin_funds_invoice_line   n,\n"
								+ "                                       fin_funds_header         l\n"
								+ "                                 where m.ALLO_ID = n.ALLO_ID\n"
								+ "                                   and m.funds_id = l.funds_id\n"
								+ "                                   and l.funds_id ="
								+ funds_id
								+ "                                   AND m.stat = 5\n"
								+ "                                   and nvl(m.sap_erp_stat, 0) = 2)) amt,\n"
								+ "                       '05' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       b.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       '暂收款确认' item_text\n"
								+ "                  from fin_funds_header b\n"
								+ "                 where b.funds_id ="
								+ funds_id
								+ "                   and b.amt > 0\n"
								+ "\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and sp.pi_id = n.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and sp.sale_ent_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "                union all\n"
								+ "                select b.cust_id,\n"
								+ "                       '暂收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       - (fact_amt - b.allocated_amt),\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       b.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       '暂收款' item_text\n"
								+ "                  from fin_funds_header b\n"
								+ "                 where b.funds_id ="
								+ funds_id
								+ "                   and b.amt > 0\n"
								+ "                   and b.allocated_amt <> b.fact_amt\n"
								+ "                   and b.fact_amt > b.allocated_amt) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  2\n"
								+ "                 else\n"
								+ "                  3\n"
								+ "               end linetype,\n"
								+ "               nvl(sum(amt), 0) amt,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '15'\n"
								+ "                 else\n"
								+ "                  '35'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1500'\n"
								+ "                 else\n"
								+ "                  '1130'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this
								.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
										ip_bldat, funds_id, 2, 5, 1, 0, 0,
										comp_code, 1,
										"跨组织-分配金额大于0 到款金额等于分配金额引ERP状态等于2 取真实客户 引暂收 ");

						if (return_ent_type == 1) {
							comp_code = "1500";
						} else {
							comp_code = "1130";
						}

						sql = "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "                 case when return_ent_type=1 then 3 else 2 end linetype,\n"
								+ "               -nvl(sum(amt), 0) amt,\n"
								+ "               case when return_ent_type=1 then '25' else  '05' end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1130'\n"
								+ "                 else\n"
								+ "                  '1500'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 1, 0, 0, comp_code,
								2,
								"跨组织-分配金额大于0 到款金额等于分配金额  引ERP状态等于2 取真实客户 引暂收 ");

					}
					*//**
					 * 12 跨组织-分配金额大于0 到款金额等于分配金额 引ERP状态等于3 取真实客户 引暂收 (跨组织) 凭证(1)
					 * 40 借 暂收(暂收客户) 1200 15 贷 客户 800 15 贷 1500 400 凭证(2) 25 借
					 * 1130 400 15 贷 客户 400
					 * *//*
					else if (factamt == allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 3 && count2 > 0 && count10 > 0) {
						// 传 erp_sap_stat==3
						sql = "select w1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '暂收款确认' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               fact_amt amt,\n"
								+ "               '05' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '暂收款确认' item_text,\n"
								+ "               '1130' COMP_CODE,\n"
								+ dictvalue
								+ "  sap_account\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union all\n"
								+ "        select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       n.pi_no item_text,\n"
								+ "                       '1130' COMP_CODE\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and sp.pi_id = n.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and sp.sale_ent_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       m.pi_no item_text,\n"
								+ "                       '1130' COMP_CODE\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       n.pi_no item_text,\n"
								+ "                       '1130' COMP_CODE\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  2\n"
								+ "                 else\n"
								+ "                  3\n"
								+ "               end linetype,\n"
								+ "               nvl(sum(amt), 0) amt,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '15'\n"
								+ "                 else\n"
								+ "                  '35'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1500'\n"
								+ "                 else\n"
								+ "                  '1130'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";
						vcline = this.getDataCentre().multiRowSelect(sql);
						this
								.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
										ip_bldat, funds_id, 2, 5, 1, 0, 0,
										comp_code, 1,
										"跨组织-分配金额大于0   到款金额等于分配金额  引ERP状态等于3 取真实客户 引暂收");

						if (return_ent_type == 1) {
							comp_code = "1500";
						} else {
							comp_code = "1130";
						}

						sql = "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "                 case when return_ent_type=1 then 3 else 2 end linetype,\n"
								+ "               -nvl(sum(amt), 0) amt,\n"
								+ "               case when return_ent_type=1 then '25' else  '05' end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1130'\n"
								+ "                 else\n"
								+ "                  '1500'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";
						vcline = this.getDataCentre().multiRowSelect(sql);
						this
								.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
										ip_bldat, funds_id, 2, 5, 1, 0, 0,
										comp_code, 2,
										"跨组织-分配金额大于0   到款金额等于分配金额  引ERP状态等于3 取真实客户 引暂收");

					}

					*//**
					 * 13 跨组织-分配金额大于0 到款金额不等于分配金额 引ERP状态等于3 取真实客户 引暂收 (跨组织)
					 * (凭证1) 05 借 暂收(暂收客户) 1200 15 贷 客户 800 15 贷 暂收(真实客户) 200 15
					 * 1500 200 (凭证2) 25 1130 200 15 客户 200
					 * *//*
					else if (factamt != allocatedamt && allocatedamt > 0
							&& erp_sap_stat == 3 && count2 > 0 && count10 > 0) {

						sql = "select w1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '暂收款确认' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               fact_amt amt,\n"
								+ "               '05' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '暂收款确认' item_text,\n"
								+ dictvalue
								+ "  sap_account\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union all\n"
								+ "        select a1.*, a2.sap_code\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and sp.pi_id = n.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and sp.sale_ent_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type = l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code\n"
								+ "                union all\n"
								+ "                select b.cust_id,\n"
								+ "                       '暂收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       - (fact_amt - b.allocated_amt),\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       b.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       '暂收款' item_text\n"
								+ "                  from fin_funds_header b\n"
								+ "                 where b.funds_id ="
								+ funds_id
								+ "                   and b.amt > 0\n"
								+ "                   and b.allocated_amt <> b.fact_amt\n"
								+ "                   and b.fact_amt > b.allocated_amt) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  2\n"
								+ "                 else\n"
								+ "                  3\n"
								+ "               end linetype,\n"
								+ "               nvl(sum(amt), 0) amt,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '15'\n"
								+ "                 else\n"
								+ "                  '35'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1500'\n"
								+ "                 else\n"
								+ "                  '1130'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type\n"
								+ "\n" + "        ) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this
								.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
										ip_bldat, funds_id, 3, 2, 1, 0, 0,
										comp_code, 1,
										"跨组织-分配金额大于0   到款金额不等于分配金额  引ERP状态等于3 取真实客户 引暂收");
						if (return_ent_type == 1) {
							comp_code = "1500";
						} else {
							comp_code = "1130";
						}

						sql = "select w1.*, rownum seq\n"
								+ "  from (select a1.*, a2.sap_code sap_account\n"
								+ "          from (select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -n.allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -m.total_allo_amt amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       m.pi_no item_text\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select l.cust_id,\n"
								+ "                       '收款' ALLOC_NMBR,\n"
								+ "                       2 linetype,\n"
								+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       '15' BSCHL,\n"
								+ "                       '' ZZ02,\n"
								+ "                       '' ZZ01,\n"
								+ "                       '' UMSKZ,\n"
								+ "                       l.currency_code,\n"
								+ "                       'SA' DOC_TYPE,\n"
								+ "                       '1130' COMP_CODE,\n"
								+ "                       n.pi_no item_text\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
								+ "               customer a2\n"
								+ "         where a1.cust_id = a2.cust_id\n"
								+ "        union all\n"
								+ "        select cust_id,\n"
								+ "               '收款'  ALLOC_NMBR,\n"
								+ "                 case when return_ent_type=1 then 3 else 2 end linetype,\n"
								+ "               -nvl(sum(amt), 0) amt,\n"
								+ "               case when return_ent_type=1 then '25' else  '05' end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '代收代付-' || "
								+ sap_code
								+ "||"
								+ pinos
								+ "  item_text,\n"
								+ "               case\n"
								+ "                 when return_ent_type = 1 then\n"
								+ "                  '1130'\n"
								+ "                 else\n"
								+ "                  '1500'\n"
								+ "               end sap_account\n"
								+ "          from (select -n.allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       fin_funds_allo_line   n,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l,\n"
								+ "                       sale_pi_header        sp\n"
								+ "                 where m.allo_id = n.allo_id\n"
								+ "                   and m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and n.pi_id = sp.pi_id\n"
								+ "                   and nvl(is_byhand, 0) <> 2\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(n.allo_amt, 0) > 0\n"
								+ "                   and l.return_ent_type <> sp.sale_ent_type\n"
								+ "                union all\n"
								+ "                select -m.total_allo_amt amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_allo_header m,\n"
								+ "                       base_contract         k,\n"
								+ "                       fin_funds_header      l\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and m.funds_id ="
								+ funds_id
								+ "                   and nvl(is_byhand, 0) = 2\n"
								+ "                   and m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                union all\n"
								+ "                select -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
								+ "                       m.cust_code,\n"
								+ "                       m.cust_id,\n"
								+ "                       m.currency_code,\n"
								+ "                       l.return_ent_type\n"
								+ "                  from fin_funds_invoice_header m,\n"
								+ "                       fin_funds_invoice_line   n,\n"
								+ "                       fin_funds_header         l,\n"
								+ "                       base_contract            k\n"
								+ "                 where m.org_id = k.org_id\n"
								+ "                   and m.ALLO_ID = n.ALLO_ID\n"
								+ "                   and m.funds_id = l.funds_id\n"
								+ "                   and l.funds_id ="
								+ funds_id
								+ "                   AND m.stat = 5\n"
								+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
								+ "                   and m.trade_type <> l.return_ent_type\n"
								+ "                 group by m.cust_code,\n"
								+ "                          m.cust_id,\n"
								+ "                          m.currency_code,\n"
								+ "                          l.return_ent_type)\n"
								+ "         group by cust_code, cust_id, currency_code, return_ent_type) w1";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this
								.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
										ip_bldat, funds_id, 3, 2, 1, 0, 0,
										comp_code, 2,
										"跨组织-分配金额大于0   到款金额不等于分配金额  引ERP状态等于3 取真实客户 引暂收");

					}

					else {
						throw new IllegalLogicException("数据异常,请检查!");
					}

				} else {

				}
			}
			// TT到款 ——转货款
			else if (funds_type == 1 && tt_type == 2 && factamt == allocatedamt
					&& count10 > 0) {

				sql = "select w1.*, rownum seq\n"
						+ "  from (select b.cust_id,\n"
						+ "               '收款' ALLOC_NMBR,\n"
						+ "               1 linetype,\n"
						+ "               fact_amt amt,\n"
						+ "               '40' BSCHL,\n"
						+ "               'A1' ZZ02,\n"
						+ "               a.account_no ZZ01,\n"
						+ "               '' UMSKZ,\n"
						+ "               b.currency_code,\n"
						+ "               'SA' DOC_TYPE,\n"
						+ "               '1130' COMP_CODE,\n"
						+ "               '收款' item_text,b.sap_account\n"
						+ "          from fin_funds_header b,bank a \n"
						+ "         where b.bank_id = a.bank_id and  b.funds_id ="
						+ funds_id
						+ "           and b.amt > 0\n"
						+ "           union\n"
						+ "           select b.cust_id,\n"
						+ "           '手续费' ALLOC_NMBR,\n"
						+ "           1 linetype,\n"
						+ "           amt_deduct amt,\n"
						+ "           '40' BSCHL,\n"
						+ "           '' ZZ02,\n"
						+ "           '' ZZ01,\n"
						+ "           '' UMSKZ,\n"
						+ "           b.currency_code,\n"
						+ "           'SA' DOC_TYPE,\n"
						+ "           '1130' COMP_CODE,\n"
						+ "           '手续费' item_text,'6603010006'sap_account\n"
						+ "           from fin_funds_header b\n"
						+ "           where b.funds_id ="
						+ funds_id
						+ "           and b.amt_deduct > 0\n"

						+ "        union all\n"
						+ "        select a1.*, a2.sap_code sap_account\n"
						+ "          from (select l.cust_id,\n"
						+ "                       '收款' ALLOC_NMBR,\n"
						+ "                       2 linetype,\n"
						+ "                       -n.allo_amt amt,\n"
						+ "                       '15' BSCHL,\n"
						+ "                       '' ZZ02,\n"
						+ "                       '' ZZ01,\n"
						+ "                       '' UMSKZ,\n"
						+ "                       l.currency_code,\n"
						+ "                       'SA' DOC_TYPE,\n"
						+ "                       '1130' COMP_CODE,n.pi_no item_text\n"
						+ "                  from fin_funds_allo_header m,\n"
						+ "                       fin_funds_allo_line   n,\n"
						+ "                       base_contract         k,\n"
						+ "                       fin_funds_header      l\n"
						+ "                 where m.allo_id = n.allo_id\n"
						+ "                   and m.org_id = k.org_id\n"
						+ "                   and m.funds_id = l.funds_id\n"
						+ "                   and nvl(is_byhand, 0) <> 2\n"
						+ "                   and m.funds_id ="
						+ funds_id
						+ "                   and m.stat = 5\n"
						+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
						+ "                   and nvl(n.allo_amt, 0) > 0\n"
						+ "                union all\n"
						+ "                select l.cust_id,\n"
						+ "                       '收款' ALLOC_NMBR,\n"
						+ "                       2 linetype,\n"
						+ "                       -m.total_allo_amt amt,\n"
						+ "                       '15' BSCHL,\n"
						+ "                       '' ZZ02,\n"
						+ "                       '' ZZ01,\n"
						+ "                       '' UMSKZ,\n"
						+ "                       l.currency_code,\n"
						+ "                       'SA' DOC_TYPE,\n"
						+ "                       '1130' COMP_CODE,m.pi_no item_text\n"
						+ "                  from fin_funds_allo_header m,\n"
						+ "                       base_contract         k,\n"
						+ "                       fin_funds_header      l\n"
						+ "                 where m.org_id = k.org_id\n"
						+ "                   and m.funds_id = l.funds_id\n"
						+ "                   and m.funds_id ="
						+ funds_id
						+ "                   and nvl(is_byhand, 0) = 2\n"
						+ "                   and m.stat = 5\n"
						+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
						+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
						+ "                union all\n"
						+ "                select l.cust_id,\n"
						+ "                       '收款' ALLOC_NMBR,\n"
						+ "                       2 linetype,\n"
						+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
						+ "                       '15' BSCHL,\n"
						+ "                       '' ZZ02,\n"
						+ "                       '' ZZ01,\n"
						+ "                       '' UMSKZ,\n"
						+ "                       l.currency_code,\n"
						+ "                       'SA' DOC_TYPE,\n"
						+ "                       '1130' COMP_CODE,n.pi_no item_text\n"
						+ "                  from fin_funds_invoice_header m,\n"
						+ "                       fin_funds_invoice_line   n,\n"
						+ "                       fin_funds_header         l,\n"
						+ "                       base_contract            k\n"
						+ "                 where m.org_id = k.org_id\n"
						+ "                   and m.ALLO_ID = n.ALLO_ID\n"
						+ "                   and m.funds_id = l.funds_id\n"
						+ "                   and l.funds_id ="
						+ funds_id
						+ "                   AND m.stat = 5\n"
						+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
						+ "                 group by l.cust_id, n.pi_no, l.currency_code) a1,\n"
						+ "               customer a2\n"
						+ "         where a1.cust_id = a2.cust_id) w1";
				vcline = this.getDataCentre().multiRowSelect(sql);

				this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline, ip_bldat,
						funds_id, 2, 5, 1, 0, 0, comp_code, 2, "TT到款	——转货款");

			}
			// LC到款
			else if (funds_type == 2) {

				if (count2 == 0) {
					int lc_cash_type = Integer.parseInt((String) ht
							.get("lc_cash_type"));// lc到款类型:1:融资到款2:还押汇3:余款到款

					if (lc_cash_type == 1 && erp_sap_stat == 1) {

						sql = "select a1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '押汇' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               'A1' ZZ02,\n"
								+ "               a.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               b.sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b, bank a\n"
								+ "\n"
								+ "         where b.bank_id = a.bank_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               '押汇手续费' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt_deduct amt,\n"
								+ "               case\n"
								+ "                 when amt_deduct > 0 then\n"
								+ "                  '40'\n"
								+ "                 else\n"
								+ "                  '50'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '6603010006' sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and nvl(b.amt_deduct, 0) < > 0\n"
								+ "        union all\n"
								+ "        select b.cust_id,\n"
								+ "               '押汇利息' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               lc_interest amt,\n"
								+ "               case\n"
								+ "                 when lc_interest > 0 then\n"
								+ "                  '40'\n"
								+ "                 else\n"
								+ "                  '50'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '6603010007' sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and nvl(b.lc_interest, 0) < > 0\n"
								+ "\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               '押汇' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -b.fact_amt amt,\n"
								+ "               '19' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               'M' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               a.sap_code sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b, customer a\n"
								+ "         where b.cust_id = a.cust_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and nvl(b.fact_amt, 0) > 0\n"
								+ "\n"
								+ "        ) a1\n"
								+ " order by linetype";

						vcline = this.getDataCentre().multiRowSelect(sql);

						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 2, 0, 0, comp_code,
								2, "LC融资到款");

					}
					// Lc还押汇：直接传应收
					else if (lc_cash_type == 2) {
						if (erp_sap_stat == 1 && factamt == allocatedamt) {

							sql = "select w1.*, rownum seq\n"
									+ "  from (select a.*, b.item_text\n"
									+ "          from (select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       amt amt,\n"
									+ "                       '09' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       'M' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       a.sap_code sap_account\n"
									+ "\n"
									+ "                  from fin_funds_header b, customer a\n"
									+ "                 where b.cust_id = a.cust_id\n"
									+ "                   and b.funds_id ="
									+ funds_id
									+ "                   and b.fact_amt > 0\n"
									+ "                union all\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇手续费' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt_deduct amt,\n"
									+ "                       case\n"
									+ "                         when amt_deduct > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010006' sap_account\n"
									+ "\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.amt_deduct, 0) < > 0\n"
									+ "                union all\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇利息' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       lc_interest amt,\n"
									+ "                       case\n"
									+ "                         when lc_interest > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010007' sap_account\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.lc_interest, 0) < > 0) a,\n"
									+ "               (select wm_concat(pi_no) item_text, funds_id\n"
									+ "                  from (select c.pi_no, l.funds_id\n"
									+ "                          from fin_funds_header l, fin_funds_line c\n"
									+ "                         where l.funds_id = c.funds_id\n"
									+ "                           and l.funds_id ="
									+ funds_id
									+ "                           and l.erp_stat <> 2\n"
									+ "                        union\n"
									+ "                        select n.pi_no, m.funds_id\n"
									+ "                          from fin_funds_invoice_header m,\n"
									+ "                               fin_funds_invoice_line   n\n"
									+ "                         where m.allo_id = n.allo_id\n"
									+ "                           and m.funds_id ="
									+ funds_id
									+ "                           AND m.stat = 5\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2)\n"
									+ "                 group by funds_id) b\n"
									+ "         where a.funds_id = b.funds_id(+)\n"
									+ "\n"
									+ "        union all\n"
									+ "        select a1.cust_id,\n"
									+ "               funds_id,\n"
									+ "                alloc_nmbr,\n"
									+ "               linetype,\n"
									+ "               amt,\n"
									+ "               BSCHL,\n"
									+ "               ZZ02,\n"
									+ "               ZZ01,\n"
									+ "               UMSKZ,\n"
									+ "               a1.currency_code,\n"
									+ "               DOC_TYPE,\n"
									+ "               COMP_CODE,\n"
									+ "               a2.sap_code sap_account,\n"
									+ "                item_text\n"
									+ "          from (select l.cust_id,\n"
									+ "                       l.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -sum(n.invoice_check_amt) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       n.pi_no item_text\n"
									+ "                  from fin_funds_invoice_header m,\n"
									+ "                       fin_funds_invoice_line   n,\n"
									+ "                       fin_funds_header         l\n"
									+ "                 where m.allo_id = n.allo_id\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and l.funds_id ="
									+ funds_id
									+ "                   AND m.stat = 5\n"
									+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                 group by l.cust_id, l.funds_id, l.currency_code, n.pi_no\n"
									+ "\n"
									+ "                union all\n"
									+ "                select l.cust_id,\n"
									+ "                       l.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -sum(c.allot_amt) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       c.pi_no item_text\n"
									+ "                  from fin_funds_header l, fin_funds_line c\n"
									+ "                 where l.funds_id = c.funds_id\n"
									+ "                   and l.funds_id ="
									+ funds_id
									+ "                   and l.erp_stat <> 2\n"
									+ "                 group by l.cust_id, l.funds_id, l.currency_code, c.pi_no) a1,\n"
									+ "               customer a2\n"
									+ "         where a1.cust_id = a2.cust_id) w1";
							vcline = this.getDataCentre().multiRowSelect(sql);
							this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
									ip_bldat, funds_id, 2, 5, 1, 0, 0,
									comp_code, 2, "Lc还押汇");
						} else {
							throw new IllegalLogicException("【" + funds_no
									+ "】未分配完成不允许导入SAP,请检查!");
						}
					}
					// LC余款到款:直接传应收
					else if (lc_cash_type == 3) {
						if (erp_sap_stat == 1 && factamt == allocatedamt) {
							sql = "select w1.*, rownum seq\n"
									+ "  from (select a.*, b.item_text\n"
									+ "          from (select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt amt,\n"
									+ "                       '40' BSCHL,\n"
									+ "                       'A1' ZZ02,\n"
									+ "                       a.account_no ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       b.sap_account\n"
									+ "                  from fin_funds_header b, bank a\n"
									+ "                 where b.bank_id = a.bank_id\n"
									+ "                   and b.funds_id ="
									+ funds_id
									+ "                   and b.fact_amt > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇手续费' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt_deduct amt,\n"
									+ "                       case\n"
									+ "                         when amt_deduct > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010006' sap_account\n"
									+ "\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.amt_deduct, 0) < > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇利息' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       lc_interest amt,\n"
									+ "                       case\n"
									+ "                         when lc_interest > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010007' sap_account\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.lc_interest, 0) < > 0) a,\n"
									+ "               (select wm_concat(pi_no) item_text, funds_id\n"
									+ "                  from (select c.pi_no, l.funds_id\n"
									+ "                          from fin_funds_header l, fin_funds_line c\n"
									+ "                         where l.funds_id = c.funds_id\n"
									+ "                           and l.funds_id ="
									+ funds_id
									+ "                           and l.erp_stat <> 2\n"
									+ "                        union\n"
									+ "                        select n.pi_no, m.funds_id\n"
									+ "                          from fin_funds_invoice_header m,\n"
									+ "                               fin_funds_invoice_line   n\n"
									+ "                         where m.allo_id = n.allo_id\n"
									+ "                           and m.funds_id ="
									+ funds_id
									+ "                           AND m.stat = 5\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2)\n"
									+ "                 group by funds_id) b\n"
									+ "         where a.funds_id = b.funds_id(+)\n"
									+ "\n"
									+ "        union\n"
									+ "        select a1.cust_id,\n"
									+ "               funds_id,\n"
									+ "               alloc_nmbr,\n"
									+ "               linetype,\n"
									+ "               amt,\n"
									+ "               BSCHL,\n"
									+ "               ZZ02,\n"
									+ "               ZZ01,\n"
									+ "               UMSKZ,\n"
									+ "               a1.currency_code,\n"
									+ "               DOC_TYPE,\n"
									+ "               COMP_CODE,\n"
									+ "               a2.sap_code sap_account,\n"
									+ "               item_text\n"
									+ "          from (select l.cust_id,\n"
									+ "                       l.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -sum(n.invoice_check_amt) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       n.pi_no item_text\n"
									+ "                  from fin_funds_invoice_header m,\n"
									+ "                       fin_funds_invoice_line   n,\n"
									+ "                       fin_funds_header         l\n"
									+ "                 where m.allo_id = n.allo_id\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and l.funds_id ="
									+ funds_id
									+ "                   AND m.stat = 5\n"
									+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                 group by l.cust_id, l.funds_id, l.currency_code, n.pi_no\n"
									+ "\n"
									+ "                union all\n"
									+ "                select l.cust_id,\n"
									+ "                       l.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -sum(c.allot_amt) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                        c.pi_no item_text\n"
									+ "                  from fin_funds_header l, fin_funds_line c\n"
									+ "                 where l.funds_id = c.funds_id\n"
									+ "                   and l.funds_id ="
									+ funds_id
									+ "                   and l.erp_stat <> 2\n"
									+ "                 group by l.cust_id, l.funds_id, l.currency_code, c.pi_no) a1,\n"
									+ "               customer a2\n"
									+ "         where a1.cust_id = a2.cust_id) w1\n"
									+ " order by linetype";
							vcline = this.getDataCentre().multiRowSelect(sql);

							this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
									ip_bldat, funds_id, 2, 5, 1, 0, 0,
									comp_code, 2, "LC余款到款");
						} else {
							throw new IllegalLogicException("【" + funds_no
									+ "】未分配完成不允许导入SAP,请检查!");
						}

					}

					// 普通信用证到款：直接传应收
					else if (lc_cash_type == 4) {

						if (erp_sap_stat == 1 && factamt == allocatedamt) {
							sql = "select w1.*, rownum seq\n"
									+ "  from (select a.*, b.item_text\n"
									+ "          from (select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '收款' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt amt,\n"
									+ "                       '40' BSCHL,\n"
									+ "                       'A1' ZZ02,\n"
									+ "                       a.account_no ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       b.sap_account\n"
									+ "                  from fin_funds_header b, bank a\n"
									+ "                 where b.bank_id = a.bank_id\n"
									+ "                   and b.funds_id ="
									+ funds_id
									+ "                   and b.fact_amt > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '收款手续费' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt_deduct amt,\n"
									+ "                       case\n"
									+ "                         when amt_deduct > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010006' sap_account\n"
									+ "\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.amt_deduct, 0) < > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '收款' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       lc_interest amt,\n"
									+ "                       case\n"
									+ "                         when lc_interest > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010007' sap_account\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.lc_interest, 0) < > 0) a,\n"
									+ "               (select wm_concat(pi_no) item_text, funds_id\n"
									+ "                  from (select c.pi_no, l.funds_id\n"
									+ "                          from fin_funds_header l, fin_funds_line c\n"
									+ "                         where l.funds_id = c.funds_id\n"
									+ "                           and l.funds_id ="
									+ funds_id
									+ "                           and l.erp_stat <> 2\n"
									+ "                        union\n"
									+ "                        select n.pi_no, m.funds_id\n"
									+ "                          from fin_funds_invoice_header m,\n"
									+ "                               fin_funds_invoice_line   n\n"
									+ "                         where m.allo_id = n.allo_id\n"
									+ "                           and m.funds_id ="
									+ funds_id
									+ "                           AND m.stat = 5\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2)\n"
									+ "                 group by funds_id) b\n"
									+ "         where a.funds_id = b.funds_id(+)\n"
									+ "\n"
									+ "        union\n"
									+ "        select a1.cust_id,\n"
									+ "               funds_id,\n"
									+ "               alloc_nmbr,\n"
									+ "               linetype,\n"
									+ "               amt,\n"
									+ "               BSCHL,\n"
									+ "               ZZ02,\n"
									+ "               ZZ01,\n"
									+ "               UMSKZ,\n"
									+ "               a1.currency_code,\n"
									+ "               DOC_TYPE,\n"
									+ "               COMP_CODE,\n"
									+ "               a2.sap_code sap_account,\n"
									+ "               item_text\n"
									+ "          from (select l.cust_id,\n"
									+ "                       l.funds_id,\n"
									+ "                       '收款' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -sum(n.invoice_check_amt) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       n.pi_no item_text\n"
									+ "                  from fin_funds_invoice_header m,\n"
									+ "                       fin_funds_invoice_line   n,\n"
									+ "                       fin_funds_header         l\n"
									+ "                 where m.allo_id = n.allo_id\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and l.funds_id ="
									+ funds_id
									+ "                   AND m.stat = 5\n"
									+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                 group by l.cust_id, l.funds_id, l.currency_code, n.pi_no\n"
									+ "\n"
									+ "                union all\n"
									+ "                select l.cust_id,\n"
									+ "                       l.funds_id,\n"
									+ "                       '收款' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -sum(c.allot_amt) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       c.pi_no item_text\n"
									+ "                  from fin_funds_header l, fin_funds_line c\n"
									+ "                 where l.funds_id = c.funds_id\n"
									+ "                   and l.funds_id ="
									+ funds_id
									+ "                   and l.erp_stat <> 2\n"
									+ "                 group by l.cust_id, l.funds_id, l.currency_code, c.pi_no) a1,\n"
									+ "               customer a2\n"
									+ "         where a1.cust_id = a2.cust_id) w1\n"
									+ " order by linetype";
							vcline = this.getDataCentre().multiRowSelect(sql);

							this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
									ip_bldat, funds_id, 2, 5, 1, 0, 0,
									comp_code, 2, "普通信用证到款：直接传应收");
						} else {
							throw new IllegalLogicException("【" + funds_no
									+ "】未分配完成不允许导入SAP,请检查!");
						}

					}
				} else {
					throw new IllegalLogicException("此【" + funds_no
							+ "】到款属于信用证【" + zhuzi + "】分配金额不能存在多个组织,请检查!");
				}

			}
			// OA到款
			else if (funds_type == 1 && tt_type > 2) {
				// OA到款——融资到款
				if (count2 == 0) {
					if (tt_type == 3 && erp_sap_stat == 1) {

						sql = "select a1.*, rownum seq\n"
								+ "  from (select b.cust_id,\n"
								+ "               '押汇' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt amt,\n"
								+ "               '40' BSCHL,\n"
								+ "               'A1' ZZ02,\n"
								+ "               a.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               b.sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b, bank a\n"
								+ "\n"
								+ "         where b.bank_id = a.bank_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.amt > 0\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               '押汇手续费' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt_deduct amt,\n"
								+ "               case\n"
								+ "                 when amt_deduct > 0 then\n"
								+ "                  '40'\n"
								+ "                 else\n"
								+ "                  '50'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '6603010006' sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and nvl(b.amt_deduct, 0) < > 0\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               '押汇利息' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               lc_interest amt,\n"
								+ "               case\n"
								+ "                 when lc_interest > 0 then\n"
								+ "                  '40'\n"
								+ "                 else\n"
								+ "                  '50'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '6603010007' sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and nvl(b.lc_interest, 0) < > 0\n"
								+ "\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               '押汇' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               -b.fact_amt amt,\n"
								+ "               '19' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               'M' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               a.sap_code sap_account,b.hth item_text\n"
								+ "          from fin_funds_header b, customer a\n"
								+ "         where b.cust_id = a.cust_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and nvl(b.fact_amt, 0) > 0\n"
								+ "\n"
								+ "        ) a1\n"
								+ " order by linetype";

						vcline = this.getDataCentre().multiRowSelect(sql);

						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 2, 0, 0, comp_code,
								2, "OA融资到款");

					}
					// OA到款——还押汇(分配PI)
					else if (tt_type == 4) {
						if (amt > 0 && factamt == allocatedamt
								&& erp_sap_stat == 1) {// 还押汇——直接传应收款

							sql = "select w1.*, rownum seq\n"
									+ "  from (select a.*, b.item_text\n"
									+ "          from (select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       amt amt,\n"
									+ "                       '09' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       'M' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       a.sap_code sap_account\n"
									+ "\n"
									+ "                  from fin_funds_header b, customer a\n"
									+ "                 where b.cust_id = a.cust_id\n"
									+ "                   and b.funds_id ="
									+ funds_id
									+ "                   and b.fact_amt > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇手续费' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt_deduct amt,\n"
									+ "                       case\n"
									+ "                         when amt_deduct > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010006' sap_account\n"
									+ "\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.amt_deduct, 0) < > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇利息' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       lc_interest amt,\n"
									+ "                       case\n"
									+ "                         when lc_interest > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010007' sap_account\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id ="
									+ funds_id
									+ "                   and nvl(b.lc_interest, 0) < > 0) a,\n"
									+ "               (select wm_concat(pi_no) item_text, funds_id\n"
									+ "                  from (select n.pi_no, m.funds_id\n"
									+ "                          from fin_funds_allo_header m, fin_funds_allo_line n\n"
									+ "                         where m.ALLO_ID = n.ALLO_ID\n"
									+ "                           AND m.stat = 5\n"
									+ "                           and nvl(is_byhand, 0) <> 2\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                           and funds_id ="
									+ funds_id
									+ "                        union\n"
									+ "                        select m.pi_no, m.funds_id\n"
									+ "                          from fin_funds_allo_header m\n"
									+ "                         where m.stat = 5\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                           and nvl(is_byhand, 0) = 2\n"
									+ "                           and funds_id ="
									+ funds_id
									+ "                        union\n"
									+ "                        select n.pi_no, m.funds_id\n"
									+ "                          from fin_funds_invoice_header m,\n"
									+ "                               fin_funds_invoice_line   n\n"
									+ "                         where m.ALLO_ID = n.ALLO_ID\n"
									+ "                           AND m.stat = 5\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                           and funds_id ="
									+ funds_id
									+ ")\n"
									+ "                 group by funds_id) b\n"
									+ "         where a.funds_id = b.funds_id(+)\n"
									+ "\n"
									+ "        union\n"
									+ "        select a1.cust_id,\n"
									+ "               funds_id,\n"
									+ "                alloc_nmbr,\n"
									+ "               linetype,\n"
									+ "               amt,\n"
									+ "               BSCHL,\n"
									+ "               ZZ02,\n"
									+ "               ZZ01,\n"
									+ "               UMSKZ,\n"
									+ "               a1.currency_code,\n"
									+ "               DOC_TYPE,\n"
									+ "               COMP_CODE,\n"
									+ "               a2.sap_code sap_account,\n"
									+ "                item_text\n"
									+ "          from (select l.cust_id,\n"
									+ "                       m.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -n.allo_amt amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       n.pi_no item_text\n"
									+ "                  from fin_funds_allo_header m,\n"
									+ "                       fin_funds_allo_line   n,\n"
									+ "                       base_contract         k,\n"
									+ "                       fin_funds_header      l\n"
									+ "                 where m.allo_id = n.allo_id\n"
									+ "                   and m.org_id = k.org_id\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and nvl(is_byhand, 0) <> 2\n"
									+ "                   and m.funds_id ="
									+ funds_id
									+ "                   and m.stat = 5\n"
									+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
									+ "                   and nvl(n.allo_amt, 0) > 0\n"
									+ "                union all\n"
									+ "                select l.cust_id,\n"
									+ "                       m.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -m.total_allo_amt amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       m.pi_no item_text\n"
									+ "                  from fin_funds_allo_header m,\n"
									+ "                       base_contract         k,\n"
									+ "                       fin_funds_header      l\n"
									+ "                 where m.org_id = k.org_id\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and m.funds_id ="
									+ funds_id
									+ "                   and nvl(is_byhand, 0) = 2\n"
									+ "                   and m.stat = 5\n"
									+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
									+ "                union all\n"
									+ "                select l.cust_id,\n"
									+ "                       m.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       n.pi_no item_text\n"
									+ "                  from fin_funds_invoice_header m,\n"
									+ "                       fin_funds_invoice_line   n,\n"
									+ "                       fin_funds_header         l,\n"
									+ "                       base_contract            k\n"
									+ "                 where m.org_id = k.org_id\n"
									+ "                   and m.ALLO_ID = n.ALLO_ID\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and l.funds_id ="
									+ funds_id
									+ "                   AND m.stat = 5\n"
									+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                 group by l.cust_id, n.pi_no, l.currency_code, m.funds_id) a1,\n"
									+ "               customer a2\n"
									+ "         where a1.cust_id = a2.cust_id) w1";
							vcline = this.getDataCentre().multiRowSelect(sql);

							this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
									ip_bldat, funds_id, 2, 5, 1, 0, 0,
									comp_code, 2, "OA到款——还押汇(分配PI)");

						} else {
							throw new IllegalLogicException("【" + funds_no
									+ "】未分配完成不允许导入SAP,请检查!");
						}
					}
					// OA到款——余款到款
					else if (tt_type == 5) {
						if (amt > 0 && factamt == allocatedamt
								&& erp_sap_stat == 1) {// 余款到款——直接传应收款 实收金额大于0

							sql = "select w1.*, rownum seq\n"
									+ "  from (select a.*, b.item_text\n"
									+ "          from (select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt amt,\n"
									+ "                       '40' BSCHL,\n"
									+ "                       'A1' ZZ02,\n"
									+ "                       a.account_no ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       b.sap_account\n"
									+ "                  from fin_funds_header b, bank a\n"
									+ "                 where b.bank_id = a.bank_id\n"
									+ "                   and b.funds_id ="
									+ funds_id
									+ "                   and b.fact_amt > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇手续费' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       amt_deduct amt,\n"
									+ "                       case\n"
									+ "                         when amt_deduct > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010006' sap_account\n"
									+ "\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id = "
									+ funds_id
									+ "                   and nvl(b.amt_deduct, 0) < > 0\n"
									+ "                union\n"
									+ "                select b.cust_id,\n"
									+ "                       b.funds_id,\n"
									+ "                       '还押汇利息' ALLOC_NMBR,\n"
									+ "                       1 linetype,\n"
									+ "                       lc_interest amt,\n"
									+ "                       case\n"
									+ "                         when lc_interest > 0 then\n"
									+ "                          '40'\n"
									+ "                         else\n"
									+ "                          '50'\n"
									+ "                       end BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       b.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       '6603010007' sap_account\n"
									+ "                  from fin_funds_header b\n"
									+ "                 where b.funds_id = "
									+ funds_id
									+ "                   and nvl(b.lc_interest, 0) < > 0) a,\n"
									+ "               (select wm_concat(pi_no) item_text, funds_id\n"
									+ "                  from (select n.pi_no, m.funds_id\n"
									+ "                          from fin_funds_allo_header m, fin_funds_allo_line n\n"
									+ "                         where m.ALLO_ID = n.ALLO_ID\n"
									+ "                           AND m.stat = 5\n"
									+ "                           and nvl(is_byhand, 0) <> 2\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                           and funds_id = "
									+ funds_id
									+ "                        union\n"
									+ "                        select m.pi_no, m.funds_id\n"
									+ "                          from fin_funds_allo_header m\n"
									+ "                         where m.stat = 5\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                           and nvl(is_byhand, 0) = 2\n"
									+ "                           and funds_id = "
									+ funds_id
									+ "                        union\n"
									+ "                        select n.pi_no, m.funds_id\n"
									+ "                          from fin_funds_invoice_header m,\n"
									+ "                               fin_funds_invoice_line   n\n"
									+ "                         where m.ALLO_ID = n.ALLO_ID\n"
									+ "                           AND m.stat = 5\n"
									+ "                           and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                           and funds_id ="
									+ funds_id
									+ ")\n"
									+ "                 group by funds_id) b\n"
									+ "         where a.funds_id = b.funds_id(+)\n"
									+ "\n"
									+ "        union\n"
									+ "        select a1.cust_id,\n"
									+ "               funds_id,\n"
									+ "                alloc_nmbr,\n"
									+ "               linetype,\n"
									+ "               amt,\n"
									+ "               BSCHL,\n"
									+ "               ZZ02,\n"
									+ "               ZZ01,\n"
									+ "               UMSKZ,\n"
									+ "               a1.currency_code,\n"
									+ "               DOC_TYPE,\n"
									+ "               COMP_CODE,\n"
									+ "               a2.sap_code sap_account,\n"
									+ "                item_text\n"
									+ "          from (select l.cust_id,\n"
									+ "                       m.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -n.allo_amt amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       n.pi_no item_text\n"
									+ "                  from fin_funds_allo_header m,\n"
									+ "                       fin_funds_allo_line   n,\n"
									+ "                       base_contract         k,\n"
									+ "                       fin_funds_header      l\n"
									+ "                 where m.allo_id = n.allo_id\n"
									+ "                   and m.org_id = k.org_id\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and nvl(is_byhand, 0) <> 2\n"
									+ "                   and m.funds_id = "
									+ funds_id
									+ "                   and m.stat = 5\n"
									+ "                   and nvl(n.sap_erp_stat, 0) <> 2\n"
									+ "                   and nvl(n.allo_amt, 0) > 0\n"
									+ "                union all\n"
									+ "                select l.cust_id,\n"
									+ "                       m.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -m.total_allo_amt amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       m.pi_no item_text\n"
									+ "                  from fin_funds_allo_header m,\n"
									+ "                       base_contract         k,\n"
									+ "                       fin_funds_header      l\n"
									+ "                 where m.org_id = k.org_id\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and m.funds_id = "
									+ funds_id
									+ "                   and nvl(is_byhand, 0) = 2\n"
									+ "                   and m.stat = 5\n"
									+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                   and nvl(m.total_allo_amt, 0) > 0\n"
									+ "                union all\n"
									+ "                select l.cust_id,\n"
									+ "                       m.funds_id,\n"
									+ "                       '还押汇' ALLOC_NMBR,\n"
									+ "                       2 linetype,\n"
									+ "                       -nvl(sum(n.INVOICE_CHECK_AMT), 0) amt,\n"
									+ "                       '15' BSCHL,\n"
									+ "                       '' ZZ02,\n"
									+ "                       '' ZZ01,\n"
									+ "                       '' UMSKZ,\n"
									+ "                       l.currency_code,\n"
									+ "                       'SA' DOC_TYPE,\n"
									+ "                       '1130' COMP_CODE,\n"
									+ "                       n.pi_no item_text\n"
									+ "                  from fin_funds_invoice_header m,\n"
									+ "                       fin_funds_invoice_line   n,\n"
									+ "                       fin_funds_header         l,\n"
									+ "                       base_contract            k\n"
									+ "                 where m.org_id = k.org_id\n"
									+ "                   and m.ALLO_ID = n.ALLO_ID\n"
									+ "                   and m.funds_id = l.funds_id\n"
									+ "                   and l.funds_id = "
									+ funds_id
									+ "                   AND m.stat = 5\n"
									+ "                   and nvl(m.sap_erp_stat, 0) <> 2\n"
									+ "                 group by l.cust_id, n.pi_no, l.currency_code, m.funds_id) a1,\n"
									+ "               customer a2\n"
									+ "         where a1.cust_id = a2.cust_id) w1  order by linetype ";

							vcline = this.getDataCentre().multiRowSelect(sql);

							this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
									ip_bldat, funds_id, 2, 5, 1, 0, 0,
									comp_code, 2, "OA到款——余款到款");

						}

						else {// 余款到款——直接传应收款 实收金额大于0 扣费等于0 利息大于0
							throw new IllegalLogicException("【" + funds_no
									+ "】未分配完成不允许导入SAP,请检查!");
						}
					}
					// OA到款——还押汇(不分配PI)
					else if (tt_type == 6) {

						sql = "select a.*, rownum seq\n" + "\n"
								+ "  from (select b.cust_id,\n"
								+ "               b.funds_id,\n"
								+ "               '还押汇' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               -fact_amt amt,\n"
								+ "               '50' BSCHL,\n"
								+ "               'B4' ZZ02,\n"
								+ "               a.account_no ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               b.sap_account,\n"
								+ "               b.hth item_text\n"
								+ "          from fin_funds_header b, bank a\n"
								+ "         where b.bank_id = a.bank_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.fact_amt > 0\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               b.funds_id,\n"
								+ "               '还押汇' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               amt_deduct amt,\n"
								+ "               case\n"
								+ "                 when amt_deduct > 0 then\n"
								+ "                  '40'\n"
								+ "                 else\n"
								+ "                  '50'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '6603010006' sap_account,\n"
								+ "               b.hth item_text\n"
								+ "\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and nvl(b.amt_deduct, 0) < > 0\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               b.funds_id,\n"
								+ "               '还押汇' ALLOC_NMBR,\n"
								+ "               1 linetype,\n"
								+ "               lc_interest amt,\n"
								+ "               case\n"
								+ "                 when lc_interest > 0 then\n"
								+ "                  '40'\n"
								+ "                 else\n"
								+ "                  '50'\n"
								+ "               end BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               '' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               '6603010007' sap_account,\n"
								+ "               b.hth item_text\n"
								+ "          from fin_funds_header b\n"
								+ "         where b.funds_id ="
								+ funds_id
								+ "           and nvl(b.lc_interest, 0) < > 0\n"
								+ "        union\n"
								+ "        select b.cust_id,\n"
								+ "               b.funds_id,\n"
								+ "               '还押汇' ALLOC_NMBR,\n"
								+ "               2 linetype,\n"
								+ "               amt amt,\n"
								+ "               '09' BSCHL,\n"
								+ "               '' ZZ02,\n"
								+ "               '' ZZ01,\n"
								+ "               'M' UMSKZ,\n"
								+ "               b.currency_code,\n"
								+ "               'SA' DOC_TYPE,\n"
								+ "               '1130' COMP_CODE,\n"
								+ "               a.sap_code sap_account,\n"
								+ "               b.hth item_text\n"
								+ "          from fin_funds_header b, customer a\n"
								+ "         where b.cust_id = a.cust_id\n"
								+ "           and b.funds_id ="
								+ funds_id
								+ "           and b.fact_amt > 0\n"
								+ "\n"
								+ "        ) a\n" + " order by linetype";

						vcline = this.getDataCentre().multiRowSelect(sql);
						this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline,
								ip_bldat, funds_id, 2, 5, 1, 0, 0, comp_code,
								2, "OA到款——还押汇(不分配PI)");

					} else {
						throw new IllegalLogicException("到款类型不正确,请检查!");
					}
				} else {
					throw new IllegalLogicException("此【" + funds_no
							+ "】到款属于OA融资【" + zhuzi + "】分配金额不能存在多个组织,请检查!");
				}

			}
		}
	}

	*//**
	 * 开票单审核时调用此方法传SAP
	 * *//*
	public void doInvoice_Header(int notice_id, String gl_date)
			throws SinocpcException {

		String sql = "";
		// 判断当 is_kaip==2 时 不准再次开票
		sql = " select sh.notice_no,nvl(sh.is_kaip,0)is_kaip from sale_ship_notice_header sh "
				+ " where is_csh=2  " + " and sh.notice_id=" + notice_id;
		Hashtable htis_kaip = this.getDataCentre().oneRowSelect(sql);
		if (htis_kaip != null) {
			if (Integer.parseInt((String) htis_kaip.get("is_kaip")) == 2) {
				throw new IllegalLogicException("此发货单<"
						+ (String) htis_kaip.get("notice_no") + ">已经开票!");
			}
		}
		// 判断当 除木托之外其余产品报关价不能等于0
		sql = " select sap.notice_no,wm_concat(erp_code)erp_code from sale_notice_sap sap where notice_id="
				+ notice_id
				+ " and sap.erp_code not like '1333200800%' "
				+ " and nvl(sap.kaip_price,0)=0 group by sap.notice_no ";
		Hashtable htkaip_price = this.getDataCentre().oneRowSelect(sql);
		if (htkaip_price != null) {

			throw new IllegalLogicException("此发货单<"
					+ (String) htkaip_price.get("notice_no") + ">以下产品<"
					+ (String) htkaip_price.get("erp_code") + ">报关价为0,不能开票!");

		}
		// 更新开票金额
		sql = "update sale_notice_sap sns\n"
				+ "                 set sns.kaip_amt = (sns.kaip_price * sns.out_qty)\n"
				+ "               where sns.notice_id = " + notice_id
				+ "                 and sns.erp_code not like '%00P'\n"
				+ "                 and sns.erp_code <> 'T15180184600'";
		this.getDataCentre().execute(sql);// 更新内外机的开票金额

		sql = "update sale_notice_sap sns\n"
				+ "               set sns.kaip_amt = nvl(round((sns.kaip_price / sns.out_qty), 2) * sns.out_qty, 0)\n"
				+ "             where sns.notice_id = " + notice_id
				+ "               and (sns.erp_code  like '%00P'\n"
				+ "               or sns.erp_code = 'T15180184600')";
		this.getDataCentre().execute(sql);// 更新配件的开票金额

		// 统计差异金额=发货-开票
		sql = "select nvl(sum(sns.out_price * sns.out_qty), 0) -\n"
				+ "       nvl(sum(sns.kaip_price * sns.out_qty), 0) -\n"
				+ "       (nvl(sum(sns.trim_amt), 0))\n" + "as kaip_amt\n"
				+ "  from sale_notice_sap sns\n" + " where sns.notice_id = "
				+ notice_id + "   and sns.erp_code not like '%00P'\n"
				+ "   and sns.erp_code <> 'T15180184600'";
		BigDecimal kaip_amt = StrToBigDecimalDef(this.getDataCentre()
				.strSelect(sql), new BigDecimal("0"));// 整机的差异金额

		sql = "select nvl(sum(sns.out_price * sns.out_qty), 0) -\n"
				+ "         nvl(sum(kaip_amt), 0) - (nvl(sum(sns.trim_amt), 0)) as trim_amt\n"
				+ "    from sale_notice_sap sns\n"
				+ "   where sns.notice_id = " + notice_id
				+ "     and (sns.erp_code like '%00P'\n"
				+ "      or sns.erp_code = 'T15180184600')";
		BigDecimal trim_amt = StrToBigDecimalDef(this.getDataCentre()
				.strSelect(sql), new BigDecimal("0"));// 配件的差异金额

		BigDecimal t_amt = kaip_amt.add(trim_amt);
		// 把差异金额放在最大金额行
		if (t_amt.compareTo(new BigDecimal("0")) != 0 && t_amt != null) {
			sql = "select max(sns.kaip_price * sns.out_qty) as amt\n"
					+ "  from sale_notice_sap sns\n"
					+ " where sns.notice_id = \n" + notice_id
					+ "   and sns.erp_code not like '%00P'\n"
					+ "   and sns.erp_code <> 'T15180184600'\n";
			BigDecimal maxamt = Util.createBigDecimal(this.getDataCentre()
					.strSelect(sql));

			sql = "select * from sale_notice_sap where notice_id="
					+ notice_id
					+ " and (kaip_price * out_qty)="
					+ maxamt
					+ " and erp_code not like '%00P' and erp_code <> 'T15180184600'";
			Vector vcpl = this.getDataCentre().multiRowSelect(sql);
			if (vcpl.size() > 0) {
				Hashtable htpl = (Hashtable) vcpl.elementAt(0);

				sql = " update sale_notice_sap sns set trim_amt=nvl(trim_amt,0)+"
						+ t_amt
						+ ","
						+ " sns.note='系统计算:"
						+ t_amt
						+ "'"
						+ " where notice_id="
						+ htpl.get("notice_id").toString()
						+ " and erp_code='"
						+ htpl.get("erp_code").toString()
						+ "'"
						+ " and ab_votes='"
						+ htpl.get("ab_votes").toString()
						+ "'"
						+ " and nvl(prod_line_id,0)="
						+ htpl.get("prod_line_id").toString()
						+ " and iv_vbeln='"
						+ htpl.get("iv_vbeln").toString()
						+ "'"
						+ " and seq="
						+ htpl.get("seq").toString()
						+ " and (kaip_price * out_qty)=" + maxamt;
				this.getDataCentre().execute(sql);

			}
		}

		sql = "select sh.notice_id,sh.notice_no,ss.delorder_sap "
				+ " from sale_ship_notice_header sh, sale_ship_notice_sap_line ss "
				+ " where sh.notice_id=ss.notice_id "
				+ " and sh.is_csh=2 and trim(delorder_sap) is not null  and trim(KAIPIAO_SAP) is null and nvl(sh.is_kaip, 0) <> 2"
				+ " and sh.notice_id=" + notice_id;
		Vector vcn = this.getDataCentre().multiRowSelect(sql);

		if (vcn.size() > 0) {
			for (int i = 0; i < vcn.size(); i++) {
				Hashtable hsn = (Hashtable) vcn.elementAt(i);

				String delorder_sap = (String) hsn.get("delorder_sap");
				String delordersap = delorder_sap.trim();

				sql = " select count(*)count1 from sale_notice_sap  where notice_id="
						+ notice_id + " and iv_vbeln='" + delordersap + "'";
				int count1 = this.getDataCentre().intSelect(sql);
				if (count1 > 0) {
					sql = "select sap.iv_vbeln,\n"
							+ "       trim(sap.seq) seq,\n"
							+ "       case when erp_code like '%00P' then round(nvl(kaip_price,0)/out_qty,2)-nvl(sap.out_price,0) else \n"
							+ "       nvl(sap.kaip_price,0) - nvl(sap.out_price,0) end  price,\n"
							+ "       'ZPR1' kschl,1 out_qty \n"
							+ "  from sale_notice_sap sap\n"
							+ " where sap.notice_id ="
							+ notice_id
							+ "   and nvl(sap.kaip_price, 0) - nvl(sap.out_price, 0) <> 0\n"
							+ "   and sap.erp_code not like '1333200800%'\n"
							+ "   and sap.iv_vbeln='" + delordersap + "'";

					if (i < 1) {
						sql += "union\n"
								+ "select ss.delorder_sap,\n"
								+ "       '1000' seq,\n"
								+ "       NOTICE_FEE,\n"
								+ "       case\n"
								+ "         when ORDER_FEE_CODE = 'ZBXF' then\n"
								+ "          'ZBX0'\n"
								+ "         else\n"
								+ "          'ZKF1'\n"
								+ "       end kschl,1 out_qty \n"
								+ "  from sale_ship_notice_fee h, sale_ship_notice_sap_line ss\n"
								+ " where h.notice_id =" + notice_id
								+ "   AND SS.delorder_sap='" + delordersap
								+ "'" + "   and h.notice_id = ss.notice_id\n"
								+ "   and nvl(NOTICE_FEE, 0) > 0\n"
								+ "   and h.order_fee_code in ('ZBXF', 'ZCIF')";
					}
					sql += "union\n"
							+ // 开票差异金额写入SAP
							"select sns.iv_vbeln,\n"
							+ "       trim(sns.seq) seq,\n"
							+ "       sns.trim_amt as price,\n"
							+ "       'ZPR1' kschl,\n" + "       sns.out_qty\n"
							+ "  from sale_notice_sap sns\n"
							+ " where sns.trim_amt <> 0\n"
							+ "   and sns.notice_id =" + notice_id;
					Vector vc = this.getDataCentre().multiRowSelect(sql);
					this
							.ZIF_OMS_WRITE_VF01(vc, notice_id, delordersap,
									gl_date);
				}

			}
		}

	}

	*//**
	 *赔款
	 * *//*
	public void ZIF_OMS_ACC_DOCUMENT_POST_F_22_PK(Hashtable hth, Vector vcline,
			String pstng_date, int funds_id, int erp_stat, int erp_sap_stat,
			int type, int allo_m_id, int allo_type, String comp_code,
			int zuzhi, String note) throws SinocpcException {

		if (this.db_connect(SCM_F22) == 2) {
			String sql = "";
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_F22); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_F22 + "在sap中没有发现");
				}

				// 表头
				JCO.Structure is_documentheader = function
						.getImportParameterList().getStructure(
								"IS_DOCUMENTHEADER");
				is_documentheader.setValue((String) hth.get("pzzs"),
						"HEADER_TXT");// 抬头-资金单号
				is_documentheader.setValue((String) hth.get("other_no"),
						"REF_DOC_NO");
				is_documentheader.setValue(comp_code, "COMP_CODE");// 组织
				is_documentheader.setValue((String) hth.get("doc_date"),
						"DOC_DATE");// 凭证中的凭证日期
				is_documentheader.setValue(pstng_date, "PSTNG_DATE");// 凭证中的过帐日期
				is_documentheader.setValue((String) hth.get("doc_type"),
						"DOC_TYPE");// 类型
				is_documentheader.setValue("", "FISC_YEAR");// 会计年度
				is_documentheader.setValue("", "FIS_PERIOD");// 会计期间

				// 更改参数
				JCO.Structure is_obj_created_info = function
						.getImportParameterList().getStructure(
								"IS_OBJ_CREATED_INFO");
				is_obj_created_info.setValue("OMS", "SOURCE_SYS");// 源系统
				is_obj_created_info.setValue((String) hth.get("fundsno"),
						"OBJ_TYP");// 对象类型
				is_obj_created_info.setValue((String) hth.get("fundsno"),
						"OBJ_KEY_EXT");// 对象关键字
				is_obj_created_info.setValue(this.getUserBean().UserId,
						"CREATED_BY_EXT");// 创建对象的人员名称

				// 总帐科目项
				JCO.ParameterList list = function.getTableParameterList();
				JCO.Table it_accountgl = list.getTable("IT_ACCOUNTGL"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					if (Integer.parseInt((String) htline.get("linetype")) == 1) {
						it_accountgl.appendRow();
						it_accountgl.setRow(i + 1);
						it_accountgl.setValue((String) htline.get("seq"),
								"ITEMNO_ACC");// 会计凭证行项目编号
						it_accountgl.setValue((String) htline
								.get("sap_account"), "GL_ACCOUNT");// 总账科目
						it_accountgl.setValue((String) htline.get("item_text"),
								"ITEM_TEXT");// 项目文本
						it_accountgl.setValue((String) htline.get("doc_type"),
								"DOC_TYPE");// 凭证类型
						it_accountgl.setValue(comp_code, "COMP_CODE");// 公司代码--COSTCENTER
						it_accountgl.setValue("", "BUS_AREA");// 业务范围
						it_accountgl.setValue("", "PROFIT_CTR");// 利润中心
						it_accountgl.setValue("", "COSTCENTER");// 成本中心
						it_accountgl
								.setValue((String) htline.get("alloc_nmbr"),
										"ALLOC_NMBR");// 分配号--PI号
					}

				}

				// 客户项目
				JCO.Table it_accountreceivable = list
						.getTable("IT_ACCOUNTRECEIVABLE"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					if (Integer.parseInt((String) htline.get("linetype")) == 2) {

						it_accountreceivable.appendRow();
						it_accountreceivable.setRow(i + 1);

						it_accountreceivable.setValue((String) htline
								.get("seq"), "ITEMNO_ACC");// 会计凭证行项目编号
						it_accountreceivable.setValue((String) htline
								.get("sap_account"), "CUSTOMER");// 客户编号
						it_accountreceivable.setValue(comp_code, "COMP_CODE");// 公司代码
						it_accountreceivable.setValue("", "PROFIT_CTR");// 利润中心
						it_accountreceivable.setValue(pstng_date, "BLINE_DATE");// 到期日计算的基限日期
						it_accountreceivable.setValue((String) htline
								.get("alloc_nmbr"), "ALLOC_NMBR");// 分配号--PI号
						it_accountreceivable.setValue((String) htline
								.get("item_text"), "ITEM_TEXT");// 文本

					}
				}

				// 供应商商项目
				JCO.Table it_accountpayable = list
						.getTable("IT_ACCOUNTPAYABLE"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);

					if (Integer.parseInt((String) htline.get("linetype")) == 3) {

						it_accountpayable.appendRow();
						it_accountpayable.setRow(i + 1);

						it_accountpayable.setValue((String) htline.get("seq"),
								"ITEMNO_ACC");// 会计凭证行项目编号
						it_accountpayable.setValue((String) htline
								.get("sap_account"), "VENDOR_NO");// 客户编号
						it_accountpayable.setValue(comp_code, "COMP_CODE");// 公司代码
						it_accountpayable.setValue("", "PROFIT_CTR");// 利润中心
						it_accountpayable.setValue(pstng_date, "BLINE_DATE");// 到期日计算的基限日期
						it_accountpayable.setValue((String) htline
								.get("alloc_nmbr"), "ALLOC_NMBR");// 分配号--PI号
						it_accountpayable.setValue((String) htline
								.get("item_text"), "ITEM_TEXT");// 文本

					}
				}

				// 货币项目
				JCO.Table IT_CURRENCYAMOUNT = list
						.getTable("IT_CURRENCYAMOUNT"); // 是一个内表。
				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					IT_CURRENCYAMOUNT.appendRow();
					IT_CURRENCYAMOUNT.setRow(i + 1);

					IT_CURRENCYAMOUNT.setValue((String) htline.get("seq"),
							"ITEMNO_ACC");// 会计凭证行项目编号
					IT_CURRENCYAMOUNT.setValue((String) htline
							.get("currency_code"), "CURRENCY");// 货币码
					IT_CURRENCYAMOUNT.setValue((String) htline.get("amt"),
							"AMT_DOCCUR");// 凭证货币金额

				}

				// 会计凭证扩展结构2：自定义
				JCO.Table it_zextension2 = list.getTable("IT_ZEXTENSION2"); // 是一个内表。
				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);

					it_zextension2.appendRow();
					it_zextension2.setRow(i + 1);

					it_zextension2
							.setValue((String) htline.get("seq"), "POSNR");// 会计凭证行项目编号
					it_zextension2.setValue((String) htline.get("bschl"),
							"BSCHL");// 记帐代码
					it_zextension2.setValue((String) htline.get("umskz"),
							"UMSKZ");// 特殊总帐标识
					it_zextension2
							.setValue((String) htline.get("zz01"), "ZZ01");// 银行账号
					it_zextension2
							.setValue((String) htline.get("zz02"), "ZZ02");// 现金流代码
				}

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);
				System.out.println(IT_CURRENCYAMOUNT);

				// 返回参数
				JCO.Table et_return = function.getTableParameterList()
						.getTable("ET_RETURN");

				// 导出参数
				JCO.ParameterList output = function.getExportParameterList();
				String msg = "";

				if (output.getString("EV_SUBRC").equals("0")) {

					if (type == 2) {
						sql = "update fin_funds_header set sap_date=sysdate,sap_no=sap_no||','||'"
								+ output.getString("EV_BELNR")
								+ "'"
								+ ",gl_date=to_date('"
								+ pstng_date
								+ "','yyyymmdd')"
								+ ",erp_sap_stat="
								+ erp_sap_stat
								+ ",erp_stat="
								+ erp_stat
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);
					}
					if (type == 1) {

						sql = "update fin_funds_header set sap_date=sysdate,sap_no=sap_no||','||'"
								+ output.getString("EV_BELNR")
								+ "'"
								+ ",gl_date=to_date('"
								+ pstng_date
								+ "','yyyymmdd')"
								+ ",erp_sap_stat="
								+ erp_sap_stat
								+ ",erp_stat="
								+ erp_stat
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);

						if (zuzhi == 2) {
							// 手工行核销
							sql = " update fin_funds_invoice_line set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id in(select allo_id from fin_funds_invoice_header where "
									+ " funds_id=" + funds_id
									+ " and nvl(sap_erp_stat,0)<>2 )";
							this.getDataCentre().update(sql);

							sql = " update fin_funds_invoice_header set sap_erp_stat=2 "
									+ " where funds_id="
									+ funds_id
									+ " and nvl(sap_erp_stat,0)<>2";
							this.getDataCentre().update(sql);

							// 到款分配
							sql = " update fin_funds_allo_line set sap_erp_stat=2 "
									+ ",sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id in(select allo_id from fin_funds_allo_header where funds_id="
									+ funds_id
									+ ")"
									+ " and nvl(sap_erp_stat,0)<>2 ";
							this.getDataCentre().update(sql);

							sql = " update fin_funds_allo_header set sap_erp_stat=2 "
									+ ",sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where funds_id="
									+ funds_id
									+ " and nvl(sap_erp_stat,0)<>2";
							this.getDataCentre().update(sql);
						}

					}
					if (type == 3) {
						if (zuzhi == 1 && comp_code.equals("1130")) {
							sql = " update bill_invoice_line  set sap_no='"
									+ output.getString("EV_BELNR") + "'"
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);

							sql = " update bill_invoice_header set is_erp_process=2,erp_time=sysdate "
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);
						}
						if (zuzhi == 2 && comp_code.equals("1130")) {
							sql = " update bill_invoice_line  set sap_no='"
									+ output.getString("EV_BELNR") + "'"
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);
						} else if (zuzhi == 1 && comp_code.equals("1500")) {

							sql = " update bill_invoice_line  set sap_no2='"
									+ output.getString("EV_BELNR") + "'"
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);

							sql = " update bill_invoice_header set is_erp_process=2,erp_time=sysdate "
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);

						}

					}
					if (type == 4) {

						sql = "update fin_funds_header set sap_date=sysdate,sap_no=sap_no||','||'"
								+ output.getString("EV_BELNR")
								+ "'"
								+ ",gl_date=to_date('"
								+ pstng_date
								+ "','yyyymmdd')"
								+ ",erp_sap_stat="
								+ erp_sap_stat
								+ ",erp_stat="
								+ erp_stat
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);
						if (allo_type == 1) {

							sql = " update fin_funds_allo_line set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id=(select allo_id from fin_funds_allo_m_header where allo_m_id ="
									+ allo_m_id
									+ ") "
									+ " and pi_no in( "
									+ " select distinct y.pi_no from fin_funds_allo_m_line y where y.allo_m_id ="
									+ allo_m_id + " and modify_amt <> 0 "
									+ "  ) ";
							this.getDataCentre().update(sql);

							sql = " update fin_funds_allo_header set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id=(select allo_id from fin_funds_allo_m_header where allo_m_id ="
									+ allo_m_id + ") ";
							this.getDataCentre().update(sql);
						} else {
							sql = " update fin_funds_invoice_line  set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where ALLO_ID=(select ALLO_ID from fin_funds_m_invoice_header where ALLO_M_ID="
									+ allo_m_id
									+ ")"
									+ " and fee_type in(select fee_type from fin_funds_m_invoice_line where ALLO_M_ID="
									+ allo_m_id + " and modify_amt <> 0)";
							this.getDataCentre().update(sql);
						}

					}
					if (type != 3) {
						this.infin_sap(funds_id, (String) hth.get("funds_no"),
								output.getString("EV_BELNR"), pstng_date, note,
								Integer.parseInt((String) hth.get("erp_stat")),
								Integer.parseInt((String) hth
										.get("erp_sap_stat")), 1, (String) hth
										.get("funds_no"), comp_code, 2, 1);
					} else {
						this.infin_sap(funds_id, (String) hth.get("funds_no"),
								output.getString("EV_BELNR"), pstng_date,
								"费用发票", Integer.parseInt((String) hth
										.get("erp_stat")), Integer
										.parseInt((String) hth
												.get("erp_sap_stat")), 1,
								(String) hth.get("funds_no"), comp_code, 2, 3);
					}

				} else {
					for (int m = 0; m < et_return.getNumRows(); m++) {
						et_return.setRow(m);
						msg = msg + et_return.getString("MESSAGE") + ";";
					}

					throw new IllegalLogicException(msg);
				}

			} catch (Exception ex) {
				if (type != 4) {

					this.getDataCentre().commit();
					ex.printStackTrace();
					throw new IllegalLogicException(ex.toString());
				}
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}

	}

	*//**
	 * 报关与发货差异写凭证
	 * 
	 * @param hth
	 * @param vcline
	 * @param pstng_date
	 * @param funds_id
	 * @param erp_stat
	 * @param erp_sap_stat
	 * @param type
	 * @param allo_m_id
	 * @param allo_type
	 * @param comp_code
	 * @param zuzhi
	 * @param note
	 * @throws SinocpcException
	 *//*
	public void ZIF_OMS_ACC_DOCUMENT_POST_F_22_CY(Hashtable hth, Vector vcline,
			String pstng_date, int customsid, String comp_code, int zuzhi,
			String note, BigDecimal amt) throws SinocpcException {

		if (this.db_connect(SCM_F22) == 2) {
			String sql = "";
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_F22); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_F22 + "在sap中没有发现");
				}

				// 表头
				JCO.Structure is_documentheader = function
						.getImportParameterList().getStructure(
								"IS_DOCUMENTHEADER");
				is_documentheader.setValue((String) hth.get("pzzs"),
						"HEADER_TXT");// 抬头-资金单号
				is_documentheader.setValue((String) hth.get("other_no"),
						"REF_DOC_NO");
				is_documentheader.setValue(comp_code, "COMP_CODE");// 组织
				is_documentheader.setValue((String) hth.get("doc_date"),
						"DOC_DATE");// 凭证中的凭证日期
				is_documentheader.setValue(pstng_date, "PSTNG_DATE");// 凭证中的过帐日期
				is_documentheader.setValue((String) hth.get("doc_type"),
						"DOC_TYPE");// 类型
				is_documentheader.setValue("", "FISC_YEAR");// 会计年度
				is_documentheader.setValue("", "FIS_PERIOD");// 会计期间

				// 更改参数
				JCO.Structure is_obj_created_info = function
						.getImportParameterList().getStructure(
								"IS_OBJ_CREATED_INFO");
				is_obj_created_info.setValue("OMS", "SOURCE_SYS");// 源系统
				is_obj_created_info.setValue((String) hth.get("fundsno"),
						"OBJ_TYP");// 对象类型
				is_obj_created_info.setValue((String) hth.get("fundsno"),
						"OBJ_KEY_EXT");// 对象关键字
				is_obj_created_info.setValue(this.getUserBean().UserId,
						"CREATED_BY_EXT");// 创建对象的人员名称

				// 总帐科目项
				JCO.ParameterList list = function.getTableParameterList();
				JCO.Table it_accountgl = list.getTable("IT_ACCOUNTGL"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					if (Integer.parseInt((String) htline.get("linetype")) == 1) {
						it_accountgl.appendRow();
						it_accountgl.setRow(i + 1);
						it_accountgl.setValue((String) htline.get("seq"),
								"ITEMNO_ACC");// 会计凭证行项目编号
						it_accountgl.setValue((String) htline
								.get("sap_account"), "GL_ACCOUNT");// 总账科目
						it_accountgl.setValue((String) htline.get("item_text"),
								"ITEM_TEXT");// 项目文本
						it_accountgl.setValue((String) htline.get("doc_type"),
								"DOC_TYPE");// 凭证类型
						it_accountgl.setValue(comp_code, "COMP_CODE");// 公司代码--COSTCENTER
						it_accountgl.setValue("", "BUS_AREA");// 业务范围
						it_accountgl.setValue("", "PROFIT_CTR");// 利润中心
						it_accountgl.setValue("", "COSTCENTER");// 成本中心
						it_accountgl
								.setValue((String) htline.get("alloc_nmbr"),
										"ALLOC_NMBR");// 分配号--PI号
					}

				}

				// 客户项目
				JCO.Table it_accountreceivable = list
						.getTable("IT_ACCOUNTRECEIVABLE"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					if (Integer.parseInt((String) htline.get("linetype")) == 2) {

						it_accountreceivable.appendRow();
						it_accountreceivable.setRow(i + 1);

						it_accountreceivable.setValue((String) htline
								.get("seq"), "ITEMNO_ACC");// 会计凭证行项目编号
						it_accountreceivable.setValue((String) htline
								.get("sap_account"), "CUSTOMER");// 客户编号
						it_accountreceivable.setValue(comp_code, "COMP_CODE");// 公司代码
						it_accountreceivable.setValue("", "PROFIT_CTR");// 利润中心
						it_accountreceivable.setValue(pstng_date, "BLINE_DATE");// 到期日计算的基限日期
						it_accountreceivable.setValue((String) htline
								.get("alloc_nmbr"), "ALLOC_NMBR");// 分配号--PI号
						it_accountreceivable.setValue((String) htline
								.get("item_text"), "ITEM_TEXT");// 文本

					}
				}

				// 供应商商项目
				JCO.Table it_accountpayable = list
						.getTable("IT_ACCOUNTPAYABLE"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);

					if (Integer.parseInt((String) htline.get("linetype")) == 3) {

						it_accountpayable.appendRow();
						it_accountpayable.setRow(i + 1);

						it_accountpayable.setValue((String) htline.get("seq"),
								"ITEMNO_ACC");// 会计凭证行项目编号
						it_accountpayable.setValue((String) htline
								.get("sap_account"), "VENDOR_NO");// 客户编号
						it_accountpayable.setValue(comp_code, "COMP_CODE");// 公司代码
						it_accountpayable.setValue("", "PROFIT_CTR");// 利润中心
						it_accountpayable.setValue(pstng_date, "BLINE_DATE");// 到期日计算的基限日期
						it_accountpayable.setValue((String) htline
								.get("alloc_nmbr"), "ALLOC_NMBR");// 分配号--PI号
						it_accountpayable.setValue((String) htline
								.get("item_text"), "ITEM_TEXT");// 文本

					}
				}

				// 货币项目
				JCO.Table IT_CURRENCYAMOUNT = list
						.getTable("IT_CURRENCYAMOUNT"); // 是一个内表。
				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					IT_CURRENCYAMOUNT.appendRow();
					IT_CURRENCYAMOUNT.setRow(i + 1);

					IT_CURRENCYAMOUNT.setValue((String) htline.get("seq"),
							"ITEMNO_ACC");// 会计凭证行项目编号
					IT_CURRENCYAMOUNT.setValue((String) htline
							.get("currency_code"), "CURRENCY");// 货币码
					IT_CURRENCYAMOUNT.setValue((String) htline.get("amt"),
							"AMT_DOCCUR");// 凭证货币金额

				}

				// 会计凭证扩展结构2：自定义
				JCO.Table it_zextension2 = list.getTable("IT_ZEXTENSION2"); // 是一个内表。
				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);

					it_zextension2.appendRow();
					it_zextension2.setRow(i + 1);

					it_zextension2
							.setValue((String) htline.get("seq"), "POSNR");// 会计凭证行项目编号
					it_zextension2.setValue((String) htline.get("bschl"),
							"BSCHL");// 记帐代码
					it_zextension2.setValue((String) htline.get("umskz"),
							"UMSKZ");// 特殊总帐标识
					it_zextension2
							.setValue((String) htline.get("zz01"), "ZZ01");// 银行账号
					it_zextension2
							.setValue((String) htline.get("zz02"), "ZZ02");// 现金流代码
				}

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);
				System.out.println(IT_CURRENCYAMOUNT);

				// 返回参数
				JCO.Table et_return = function.getTableParameterList()
						.getTable("ET_RETURN");

				// 导出参数
				JCO.ParameterList output = function.getExportParameterList();
				String msg = "";

				if (output.getString("EV_SUBRC").equals("0")) {
					sql = "update sale_customs_header set sap_date=sysdate,sap_no='"
							+ output.getString("EV_BELNR")
							+ "'"
							+ ",modify_amt="
							+ amt
							+ " where customs_id="
							+ customsid;
					this.getDataCentre().update(sql);
				} else {
					for (int m = 0; m < et_return.getNumRows(); m++) {
						et_return.setRow(m);
						msg = msg + et_return.getString("MESSAGE") + ";";
					}

					throw new IllegalLogicException(msg);
				}

			} catch (Exception ex) {

				this.getDataCentre().commit();
				ex.printStackTrace();
				throw new IllegalLogicException(ex.toString());

			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}

	}

	*//**
	 *创建到款凭证 F-22 Hashtable hth, 主数据 Vector vcline, 行信息 String pstng_date,记账日期
	 * int funds_id, 单据号 int erp_stat, 状态 int erp_sap_stat,当前引入状态 int type,类型
	 * 1：到款单分配 2：到款引暂收 3：费用发票 4：变更调整 int allo_m_id,变更单号 int allo_type,变更类型
	 * String comp_code 引入组织 int zuzhi 是否跨组织引用1:否 2:是 int is_kforgys 当到款组织是1500
	 * ,1130组织有引用时 1500是1130的客户,传1，否者传 2
	 * *//*

	public void ZIF_OMS_ACC_DOCUMENT_POST_F_22(Hashtable hth, Vector vcline,
			String pstng_date, int funds_id, int erp_stat, int erp_sap_stat,
			int type, int allo_m_id, int allo_type, String comp_code,
			int zuzhi, String note) throws SinocpcException {
		if (this.db_connect(SCM_F22) == 2) {
			String sql = "";
			JCO.Function function = null;
			try {
				getConnection();
				function = createFunction(SCM_F22); // 取物料数据表
				if (function == null) {
					System.out.println(SCM_F22 + "在sap中没有发现");
				}

				// 表头
				JCO.Structure is_documentheader = function
						.getImportParameterList().getStructure(
								"IS_DOCUMENTHEADER");
				is_documentheader.setValue((String) hth.get("pzzs"),
						"HEADER_TXT");// 抬头-资金单号
				is_documentheader.setValue((String) hth.get("other_no"),
						"REF_DOC_NO");
				is_documentheader.setValue(comp_code, "COMP_CODE");// 组织
				is_documentheader.setValue((String) hth.get("doc_date"),
						"DOC_DATE");// 凭证中的凭证日期
				is_documentheader.setValue(pstng_date, "PSTNG_DATE");// 凭证中的过帐日期
				is_documentheader.setValue((String) hth.get("doc_type"),
						"DOC_TYPE");// 类型
				is_documentheader.setValue("", "FISC_YEAR");// 会计年度
				is_documentheader.setValue("", "FIS_PERIOD");// 会计期间

				// 更改参数
				JCO.Structure is_obj_created_info = function
						.getImportParameterList().getStructure(
								"IS_OBJ_CREATED_INFO");
				is_obj_created_info.setValue("OMS", "SOURCE_SYS");// 源系统
				if (zuzhi == 1) {
					is_obj_created_info.setValue((String) hth.get("fundsno"),
							"OBJ_TYP");// 对象类型
					is_obj_created_info.setValue((String) hth.get("fundsno"),
							"OBJ_KEY_EXT");// 对象关键字
				} else {
					is_obj_created_info.setValue((String) hth.get("fundsno")
							+ comp_code, "OBJ_TYP");// 对象类型
					is_obj_created_info.setValue((String) hth.get("fundsno")
							+ comp_code, "OBJ_KEY_EXT");// 对象关键字
				}
				is_obj_created_info.setValue(this.getUserBean().UserId,
						"CREATED_BY_EXT");// 创建对象的人员名称

				// 总帐科目项
				JCO.ParameterList list = function.getTableParameterList();
				JCO.Table it_accountgl = list.getTable("IT_ACCOUNTGL"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					if (Integer.parseInt((String) htline.get("linetype")) == 1) {
						it_accountgl.appendRow();
						it_accountgl.setRow(i + 1);
						it_accountgl.setValue((String) htline.get("seq"),
								"ITEMNO_ACC");// 会计凭证行项目编号
						it_accountgl.setValue((String) htline
								.get("sap_account"), "GL_ACCOUNT");// 总账科目
						it_accountgl.setValue((String) htline.get("item_text"),
								"ITEM_TEXT");// 项目文本
						it_accountgl.setValue((String) htline.get("doc_type"),
								"DOC_TYPE");// 凭证类型
						it_accountgl.setValue(comp_code, "COMP_CODE");// 公司代码--COSTCENTER
						it_accountgl.setValue("K100", "BUS_AREA");// 业务范围
						it_accountgl.setValue("A1140", "PROFIT_CTR");// 利润中心
						String hyf = (String) htline.get("sap_account");
						sql = " select nvl(is_sendcbzx,0) from crm_sap_finance_subjects where subjects_no='"
								+ hyf + "'" + " and rownum=1";
						int is_sendcbzx = this.getDataCentre().intSelect(sql);
						if (type == 3 && is_sendcbzx == 2) {
							it_accountgl.setValue((String) hth
									.get("costcenter"), "COSTCENTER");// 成本中心
						}
						it_accountgl
								.setValue((String) htline.get("alloc_nmbr"),
										"ALLOC_NMBR");// 分配号--PI号
					}

				}

				// 客户项目
				JCO.Table it_accountreceivable = list
						.getTable("IT_ACCOUNTRECEIVABLE"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					if (Integer.parseInt((String) htline.get("linetype")) == 2) {

						it_accountreceivable.appendRow();
						it_accountreceivable.setRow(i + 1);

						it_accountreceivable.setValue((String) htline
								.get("seq"), "ITEMNO_ACC");// 会计凭证行项目编号
						it_accountreceivable.setValue((String) htline
								.get("sap_account"), "CUSTOMER");// 客户编号
						it_accountreceivable.setValue(comp_code, "COMP_CODE");// 公司代码
						it_accountreceivable.setValue("A1140", "PROFIT_CTR");// 利润中心
						int rongzitype = Integer.parseInt((String) hth
								.get("rongzitype"));
						if (rongzitype == 1) {
							it_accountreceivable.setValue((String) hth
									.get("rongzi_dqdate"), "BLINE_DATE");// 到期日计算的基限日期
						} else {
							it_accountreceivable.setValue(pstng_date,
									"BLINE_DATE");// 到期日计算的基限日期
						}

						it_accountreceivable.setValue((String) htline
								.get("alloc_nmbr"), "ALLOC_NMBR");// 分配号--PI号
						it_accountreceivable.setValue((String) htline
								.get("item_text"), "ITEM_TEXT");// 文本

					}
				}

				// 供应商商项目
				JCO.Table it_accountpayable = list
						.getTable("IT_ACCOUNTPAYABLE"); // 是一个内表。

				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);

					if (Integer.parseInt((String) htline.get("linetype")) == 3) {

						it_accountpayable.appendRow();
						it_accountpayable.setRow(i + 1);

						it_accountpayable.setValue((String) htline.get("seq"),
								"ITEMNO_ACC");// 会计凭证行项目编号
						it_accountpayable.setValue((String) htline
								.get("sap_account"), "VENDOR_NO");// 客户编号
						it_accountpayable.setValue(comp_code, "COMP_CODE");// 公司代码
						it_accountpayable.setValue("A1140", "PROFIT_CTR");// 利润中心
						int rongzitype = Integer.parseInt((String) hth
								.get("rongzitype"));
						it_accountpayable.setValue(pstng_date, "BLINE_DATE");// 到期日计算的基限日期

						it_accountpayable.setValue((String) htline
								.get("alloc_nmbr"), "ALLOC_NMBR");// 分配号--PI号
						it_accountpayable.setValue((String) htline
								.get("item_text"), "ITEM_TEXT");// 文本

					}
				}

				// 货币项目
				JCO.Table IT_CURRENCYAMOUNT = list
						.getTable("IT_CURRENCYAMOUNT"); // 是一个内表。
				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);
					IT_CURRENCYAMOUNT.appendRow();
					IT_CURRENCYAMOUNT.setRow(i + 1);

					IT_CURRENCYAMOUNT.setValue((String) htline.get("seq"),
							"ITEMNO_ACC");// 会计凭证行项目编号
					IT_CURRENCYAMOUNT.setValue((String) htline
							.get("currency_code"), "CURRENCY");// 货币码
					IT_CURRENCYAMOUNT.setValue((String) htline.get("amt"),
							"AMT_DOCCUR");// 凭证货币金额

				}

				// 会计凭证扩展结构2：自定义
				JCO.Table it_zextension2 = list.getTable("IT_ZEXTENSION2"); // 是一个内表。
				for (int i = 0; i < vcline.size(); i++) {
					Hashtable htline = (Hashtable) vcline.elementAt(i);

					it_zextension2.appendRow();
					it_zextension2.setRow(i + 1);

					it_zextension2
							.setValue((String) htline.get("seq"), "POSNR");// 会计凭证行项目编号
					it_zextension2.setValue((String) htline.get("bschl"),
							"BSCHL");// 记帐代码
					it_zextension2.setValue((String) htline.get("umskz"),
							"UMSKZ");// 特殊总帐标识
					it_zextension2
							.setValue((String) htline.get("zz01"), "ZZ01");// 银行账号
					it_zextension2
							.setValue((String) htline.get("zz02"), "ZZ02");// 现金流代码
				}

				if (mConnection == null) {
					System.out.println("mConnection 为空");
				}

				mConnection.execute(function);
				System.out.println(IT_CURRENCYAMOUNT);

				// 返回参数
				JCO.Table et_return = function.getTableParameterList()
						.getTable("ET_RETURN");

				// 导出参数
				JCO.ParameterList output = function.getExportParameterList();
				String msg = "";

				if (output.getString("EV_SUBRC").equals("0")) {

					if (type == 2) {
						sql = "update fin_funds_header set sap_date=sysdate,sap_no=sap_no||','||'"
								+ output.getString("EV_BELNR")
								+ "'"
								+ ",gl_date=to_date('"
								+ pstng_date
								+ "','yyyymmdd')"
								+ ",erp_sap_stat="
								+ erp_sap_stat
								+ ",erp_stat="
								+ erp_stat
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);
					}
					if (type == 1) {

						sql = "update fin_funds_header set sap_date=sysdate,sap_no=sap_no||','||'"
								+ output.getString("EV_BELNR")
								+ "'"
								+ ",gl_date=to_date('"
								+ pstng_date
								+ "','yyyymmdd')"
								+ ",erp_sap_stat="
								+ erp_sap_stat
								+ ",erp_stat="
								+ erp_stat
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);

						if (zuzhi == 2) {
							// 手工行核销
							sql = " update fin_funds_invoice_line set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id in(select allo_id from fin_funds_invoice_header where "
									+ " funds_id=" + funds_id
									+ " and nvl(sap_erp_stat,0)<>2 )";
							this.getDataCentre().update(sql);

							sql = " update fin_funds_invoice_header set sap_erp_stat=2 "
									+ " where funds_id="
									+ funds_id
									+ " and nvl(sap_erp_stat,0)<>2";
							this.getDataCentre().update(sql);

							// 到款分配
							sql = " update fin_funds_allo_line set sap_erp_stat=2 "
									+ ",sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id in(select allo_id from fin_funds_allo_header where funds_id="
									+ funds_id
									+ ")"
									+ " and nvl(sap_erp_stat,0)<>2 ";
							this.getDataCentre().update(sql);

							sql = " update fin_funds_allo_header set sap_erp_stat=2 "
									+ ",sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where funds_id="
									+ funds_id
									+ " and nvl(sap_erp_stat,0)<>2";
							this.getDataCentre().update(sql);
						}

					}
					if (type == 3) {
						if (zuzhi == 1 && comp_code.equals("1130")) {
							sql = " update bill_invoice_line  set sap_no='"
									+ output.getString("EV_BELNR") + "'"
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);

							sql = " update bill_invoice_header set is_erp_process=2,erp_time=sysdate "
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);
						}
						if (zuzhi == 2 && comp_code.equals("1130")) {
							sql = " update bill_invoice_line  set sap_no='"
									+ output.getString("EV_BELNR") + "'"
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);
						} else if (zuzhi == 1 && comp_code.equals("1500")) {

							sql = " update bill_invoice_line  set sap_no2='"
									+ output.getString("EV_BELNR") + "'"
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);

							sql = " update bill_invoice_header set is_erp_process=2,erp_time=sysdate "
									+ " where invoice_id =" + funds_id;
							this.getDataCentre().update(sql);

						}

					}
					if (type == 4) {

						sql = "update fin_funds_header set sap_date=sysdate,sap_no=sap_no||','||'"
								+ output.getString("EV_BELNR")
								+ "'"
								+ ",gl_date=to_date('"
								+ pstng_date
								+ "','yyyymmdd')"
								+ ",erp_sap_stat="
								+ erp_sap_stat
								+ ",erp_stat="
								+ erp_stat
								+ " where funds_id=" + funds_id;
						this.getDataCentre().update(sql);
						if (allo_type == 1) {

							sql = " update fin_funds_allo_line set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id=(select allo_id from fin_funds_allo_m_header where allo_m_id ="
									+ allo_m_id
									+ ") "
									+ " and pi_no in( "
									+ " select distinct y.pi_no from fin_funds_allo_m_line y where y.allo_m_id ="
									+ allo_m_id + " and modify_amt <> 0 "
									+ "  ) ";
							this.getDataCentre().update(sql);

							sql = " update fin_funds_allo_header set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where allo_id=(select allo_id from fin_funds_allo_m_header where allo_m_id ="
									+ allo_m_id + ") ";
							this.getDataCentre().update(sql);
						} else {
							sql = " update fin_funds_invoice_line  set sap_no='"
									+ output.getString("EV_BELNR")
									+ "'"
									+ " where ALLO_ID=(select ALLO_ID from fin_funds_m_invoice_header where ALLO_M_ID="
									+ allo_m_id
									+ ")"
									+ " and fee_type in(select fee_type from fin_funds_m_invoice_line where ALLO_M_ID="
									+ allo_m_id + " and modify_amt <> 0)";
							this.getDataCentre().update(sql);
						}

					}
					if (type != 3) {
						this.infin_sap(funds_id, (String) hth.get("funds_no"),
								output.getString("EV_BELNR"), pstng_date, note,
								Integer.parseInt((String) hth.get("erp_stat")),
								Integer.parseInt((String) hth
										.get("erp_sap_stat")), 1, (String) hth
										.get("funds_no"), comp_code, 2, 1);
					} else {
						this.infin_sap(funds_id, (String) hth.get("funds_no"),
								output.getString("EV_BELNR"), pstng_date,
								"费用发票", Integer.parseInt((String) hth
										.get("erp_stat")), Integer
										.parseInt((String) hth
												.get("erp_sap_stat")), 1,
								(String) hth.get("funds_no"), comp_code, 2, 3);
					}

					// 手工创建数据连接数据库
					com.sinocc.systemdbmanager.CPCDao data;
					if (this.getVaultBean() == null) {
						data = new com.sinocc.systemdbmanager.CPCDao("1");
					} else {
						data = new com.sinocc.systemdbmanager.CPCDao(this
								.getVaultBean().getVaultId());
					}
					data.setTransation(true);
					try {

						data.commit();
					} catch (DatabaseException databaseexception) {
						data.rollback();
						throw databaseexception;
					} finally {
						data.freeConnection();
					}

				} else {
					for (int m = 0; m < et_return.getNumRows(); m++) {
						et_return.setRow(m);
						msg = msg + et_return.getString("MESSAGE") + ";";
					}

					throw new IllegalLogicException(msg);
				}

			} catch (Exception ex) {
				if (type != 4) {

					this.getDataCentre().commit();
					ex.printStackTrace();
					throw new IllegalLogicException(ex.toString());
				}
			} finally {
				if (mConnection != null) {
					mConnection.disconnect();
				}

			}
		}

	}

	*//**
	 *记录到款到凭证
	 * *//*
	public void infin_sap(int funds_id, String funds_no, String sap_no,
			String ip_budat, String note, int erp_stat, int erp_sap_stat,
			int fin_stat, String finfunds_code, String org_code, int usable,
			int temp_type) throws SinocpcException {

		String sql = "select nvl(max(sap_id),0)+1 from fin_funds_sap "
				+ " where funds_id=" + funds_id + " and temp_type=" + temp_type;
		com.dmcrm.finman.Fin_Funds_Sap sap = new com.dmcrm.finman.Fin_Funds_Sap(
				getDataCentre());
		sap.setParent(this);
		sap.Funds_Id = funds_id;
		sap.Funds_No = funds_no;
		sap.Sap_Id = this.getDataCentre().intSelect(sql);
		sap.Sap_No = sap_no;
		sap.Note = note;
		sap.Gl_Date = ip_budat;
		sap.Erp_Sap_Stat = erp_sap_stat;
		sap.Erp_Stat = erp_stat;
		sap.Fin_Stat = fin_stat;
		sap.Finfunds_Code = finfunds_code;
		sap.Org_Code = org_code;
		sap.Usable = usable;
		sap.Temp_Type = temp_type;
		DataCentreObject getDao = null;
		getDataCentre().insert(sap);

	}

	*//**
	 * 生产通知单审核最后一步调用此方法传SAP生成SAP的标准销售单
	 * *//*
	public void doProd_Header(int prod_id, String line_type)
			throws SinocpcException {
		String sql = "";

		*//**
		 * 判断形式发票类型除内销,配件、以外都写SAP:sale_order_type
		 * *//*
		if (this.db_connect(SCM_VA01) == 2) {

			sql = " select a1.prod_id,a2.zone_code sap_zone_code,a2.sap_org_code,to_char(a1.check_time,'yyyymmdd')check_time,a1.pi_no,a1.price_type_name, "
					+ " a1.area_name,a1.area_id,a5.pay_condition,a1.currency_code,a5.erp_type_id,a5.payment_type_code,"
					+ " a1.prod_no||'Z' prod_no,a4.sap_code cust_code,a1.sales_user_id, "
					+ " a6.sap_zuzhi sales_org,inspection_batchno "
					+ " from sale_prod_header a1,base_contract a2,customer a4, payment_type a5,sap_orggckcdz a6  "
					+ " where a1.org_id=a2.org_id "
					+ " and a1.cust_id=a4.cust_id "
					+ " and a1.payment_type_id=a5.payment_type_id "
					+ " and a1.sale_ent_type=a6.sale_ent_type "
					+ " and prod_id=" + prod_id;

			Hashtable hth = this.getDataCentre().oneRowSelect(sql);

			if (!line_type.equals("4")) {
				sql = "select m.prod_no,m.prod_id,m.pi_no,m.pi_id, n.prod_qty qty,n.price,n.erp_code,n.cust_spec,c.brand_name,  "
						+ " case when  item_name  like '%木底托%' then '' else  a6.sap_kuwei  end store_loc,  "
						+ " a6.sap_gongc plant,"
						+ " rownum seq,m.currency_code,n.deliver_date "
						+ " from sale_prod_header m,sale_prod_h_line c , sale_prod_line n,sap_orggckcdz a6  "
						+ " where m.prod_id=n.prod_id "
						+ " and m.prod_id=c.prod_id "
						+ " and n.prod_h_id=c.prod_h_id "
						+ " and m.sale_ent_type=a6.sale_ent_type "
						+ " and n.prod_qty>0 "
						+ " and m.prod_id="
						+ prod_id
						+ " and n.line_type in("
						+ line_type
						+ ")"
						+ " order by n.pro_type, n.prod_line_id ";
			} else {
				sql = "select * from (select m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty qty,t.price,n.erp_code,n.cust_spec,c.brand_name,  "
						+ " a6.sap_kuwei store_loc,"
						+ " a6.sap_gongc plant,"
						+ " 1 seq,m.currency_code,n.deliver_date "
						+ " from sale_prod_header m,sale_prod_h_line c , sale_prod_line n ,sale_prod_package t,sap_orggckcdz a6 "
						+ " where m.prod_id=n.prod_id "
						+ " and m.prod_id=c.prod_id "
						+ " and n.prod_h_id=c.prod_h_id "
						+ " and m.prod_id=t.prod_id "
						+ " and m.sale_ent_type=a6.sale_ent_type "
						+ " and t.pack_qty>0   "
						+ " and m.prod_id="
						+ prod_id
						+ " and n.line_type in("
						+ line_type
						+ ")"
						+ " group by m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty ,"
						+ " t.price,n.erp_code,n.cust_spec,c.brand_name,c.CUST_ITEM_NAME,n.deliver_date, "
						+ " m.sale_ent_type	,m.currency_code,a6.sap_kuwei ,a6.sap_gongc ,rownum "
						+ " order by deliver_date  ) where   rownum=1 ";
			}

			Vector vc = this.getDataCentre().multiRowSelect(sql);
			if (hth != null && vc.size() > 0) {
				this.putZRFC_SD_WRITE_VA01(vc, hth, line_type);
			}

		}

	}

	*//**
	 * 生产通知单审核最后一步调用此方法传SAP生成SAP的标准采购单、采购退货单
	 * *//*
	public void doProd_M_Header(int prod_id) throws SinocpcException {
		String sql = "";
		String sap_no = "";

		sql = "   select change_type "
				+ " from sale_prod_m_header a, sale_prod_header b "
				+ " where prod_m_id =" + prod_id
				+ " and a.prod_id = b.prod_id " + " and nvl(b.is_csh,0) < 2 "
				+ " and nvl(b.is_sap,0) = 2 ";
		int change_type = this.getDataCentre().intSelect(sql);

		if (change_type == 1 || change_type == 3) {
			sql = "   select count(*) from Sale_Prod_M_H_Line sl where sl.prod_m_id="
					+ prod_id + " and sl.line_type <>4";
			if (this.getDataCentre().intSelect(sql) == 0) {
				sql = "select distinct (j3.sap_no) sap_no\n"
						+ "  from sale_prod_m_line j1, sale_prod_sap j2, sale_prod_line j3,Sale_Prod_Package spp\n"
						+ " where j1.prod_m_id = \n" + prod_id
						+ "   and j1.erp_code = j2.erp_code\n"
						+ "   and j1.erp_code = j3.erp_code\n"
						+ "   and j1.prod_id = j3.prod_id\n"
						+ "   and j3.prod_id = spp.prod_id\n"
						+ "   and spp.pack_qty >0";
				sap_no = this.getDataCentre().strSelect(sql);
				if (sap_no != null && sap_no.trim().length() > 0) {
					sql = "select (select to_char(deliver_date, 'yyyymmdd')\n"
							+ "          from sale_prod_m_h_line\n"
							+ "         where prod_m_id = \n" + prod_id
							+ "           and rownum = 1) deliver_date,\n"
							+ "       pack_qty qty,\n"
							+ "       (select sap_no\n"
							+ "          from sale_prod_line pl\n"
							+ "         where pl.prod_id = b.prod_id\n"
							+ "           and rownum = 1) sap_no,\n"
							+ "       a.seq,\n"
							+ "       substr(10000 + a.seq, 2) sched_line\n"
							+ "  From sale_prod_sap a, sale_prod_package b\n"
							+ " where a.prod_id = b.prod_id\n"
							+ "   and a.prod_id = (select prod_id\n"
							+ "                      from sale_prod_m_h_line\n"
							+ "                     where prod_m_id = \n"
							+ prod_id
							+ "                       and rownum = 1)\n"
							+ "   and b.pack_qty > 0";
					Vector vcqty1 = this.getDataCentre().multiRowSelect(sql);

					if (sap_no != null && sap_no.trim().length() > 0
							&& vcqty1.size() > 0) {
						this.putZIF_OMS_SALESORDER_CHANGE_VA02(vcqty1, sap_no,
								3, "", "", "", "", prod_id);
					}
					sql = "select *"
							+ "  from (select t.price, j2.seq,n.sap_no"
							+ "          from sale_prod_header  m,"
							+ "               sale_prod_h_line  c,"
							+ "               sale_prod_line    n,"
							+ "               sale_prod_package t,"
							+ "               sap_orggckcdz     a6,"
							+ "               sale_prod_sap     j2"
							+ "         where m.prod_id = n.prod_id"
							+ "           and m.prod_id = c.prod_id"
							+ "           and n.prod_h_id = c.prod_h_id"
							+ "           and m.prod_id = t.prod_id"
							+ "           and n.prod_id = j2.prod_id"
							+ "           and m.sale_ent_type = a6.sale_ent_type"
							+ "           and t.pack_qty > 0"
							+ "           and m.prod_id = (select sp.prod_id"
							+ "                              from sale_prod_m_header sp"
							+ "                             where sp.prod_m_id = "
							+ prod_id + ")" + "           and n.line_type = 4)"
							+ " where rownum = 1";

					Vector vc1 = this.getDataCentre().multiRowSelect(sql);

					if (sap_no != null && sap_no.trim().length() > 0
							&& vcqty1.size() > 0) {
						this.putZIF_OMS_SALESORDER_CHANGE_VA02(vc1, sap_no, 2,
								"", "", "", "", prod_id);
					}

				}

			} else {
				sql = "select distinct(j3.sap_no)sap_no from sale_prod_m_line j1,sale_prod_sap j2,sale_prod_line j3 where "
						+ " j1.prod_m_id="
						+ prod_id
						+ " and j1.erp_code=j2.erp_code "
						+ " and j1.erp_code=j3.erp_code "
						+ " and j1.prod_id=j3.prod_id "
						+ " and j1.line_type<>4";
				sap_no = this.getDataCentre().strSelect(sql);

				if (change_type == 1) {
					sql = "select to_char(j4.deliver_date,'yyyymmdd')deliver_date,\n"
							+ " j1.prod_qty+j1.modify_qty qty, j3.sap_no,j2.seq,substr(10000+j2.seq,2)sched_line\n"
							+ " from sale_prod_m_line j1,sale_prod_sap j2,sale_prod_line j3,sale_prod_m_h_line j4 where \n"
							+ " j1.prod_m_id="
							+ prod_id
							+ " and j1.erp_code=j2.erp_code \n"
							+ " and j1.erp_code=j3.erp_code \n"
							+ " and j1.prod_id=j3.prod_id \n"
							+ " and j2.prod_id=j3.prod_id \n"
							+ " and j1.prod_h_id=j4.prod_h_id\n"
							+ " and j1.prod_m_id=j4.prod_m_id\n"
							+ " and j1.prod_qty>0\n "
							+ " and j1.modify_qty<>0\n"
							+ " and j1.prod_qty+j1.modify_qty>0 ";
				} else {
					sql = "select distinct to_char(j4.deliver_date,'yyyymmdd')deliver_date,\n"
							+ " j1.prod_qty+j1.modify_qty qty, j3.sap_no,j2.seq,substr(10000+j2.seq,2)sched_line\n"
							+ " from sale_prod_m_line j1,sale_prod_sap j2,sale_prod_line j3,sale_prod_m_h_line j4 where \n"
							+ " j1.prod_m_id="
							+ prod_id
							+ " and j1.erp_code=j2.erp_code \n"
							+ " and j1.erp_code=j3.erp_code \n"
							+ " and j1.prod_id=j3.prod_id \n"
							+ " and j2.prod_id=j3.prod_id \n"
							+ " and j1.prod_h_id=j4.prod_h_id\n"
							+ " and j1.prod_m_id=j4.prod_m_id\n"
							+ " and j1.prod_qty>0\n "
							+ " and j1.prod_qty+j1.modify_qty>0 ";

				}
				// 变更之后数量大于0的修改
				Vector vcqty = this.getDataCentre().multiRowSelect(sql);

				if (sap_no != null && sap_no.trim().length() > 0
						&& vcqty.size() > 0) {
					this.putZIF_OMS_SALESORDER_CHANGE_VA02(vcqty, sap_no, 3,
							"", "", "", "", prod_id);
				}
				// 变更之后数量等于0的修改

				if (change_type == 1) {
					sql = "select to_char(j4.deliver_date,'yyyymmdd')deliver_date,\n"
							+ " j1.prod_qty+j1.modify_qty qty, j3.sap_no,j2.seq,substr(10000+j2.seq,2)sched_line\n"
							+ " from sale_prod_m_line j1,sale_prod_sap j2,sale_prod_line j3,sale_prod_m_h_line j4 where \n"
							+ " j1.prod_m_id="
							+ prod_id
							+ " and j1.erp_code=j2.erp_code \n"
							+ " and j1.erp_code=j3.erp_code \n"
							+ " and j1.prod_id=j3.prod_id \n"
							+ " and j2.prod_id=j3.prod_id \n"
							+ " and j1.prod_h_id=j4.prod_h_id\n"
							+ " and j1.prod_m_id=j4.prod_m_id\n"
							+ " and j1.prod_qty>0\n "
							+ " and j1.modify_qty<>0\n"
							+ " and nvl(j1.prod_qty+j1.modify_qty,0)=0 ";
					Vector vcqty1 = this.getDataCentre().multiRowSelect(sql);

					if (sap_no != null && sap_no.trim().length() > 0
							&& vcqty1.size() > 0) {
						this.putZIF_OMS_SALESORDER_CHANGE_VA02(vcqty1, sap_no,
								5, "", "", "", "", prod_id);
					}
				}

			}

		}

	}

	*//**
	 * 生成通知变更
	 * *//*
	public void doInprod(int prod_id, String line_type) throws SinocpcException {
		String sql = "";

		sql = "select nvl(max(seq),0)seq,iv_vbeln from sale_prod_sap where prod_id="
				+ prod_id + " group by iv_vbeln ";
		Hashtable ht = this.getDataCentre().oneRowSelect(sql);

		if (ht != null) {
			sql = "select n.*,rownum+"
					+ (String) ht.get("seq")
					+ " seq from "
					+ " (select m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty qty,t.price,n.erp_code,n.cust_spec,c.brand_name,  "
					+ " case when m.sale_ent_type=2 then '1300' else '1391' end store_loc,"
					+ " case when m.sale_ent_type=2 then '1130' else '1100' end plant,"
					+ " m.currency_code,n.deliver_date "
					+ " from sale_prod_header m,sale_prod_h_line c , sale_prod_line n ,sale_prod_package t "
					+ " where m.prod_id=n.prod_id "
					+ " and m.prod_id=c.prod_id "
					+ " and n.prod_h_id=c.prod_h_id "
					+ " and m.prod_id=t.prod_id "
					+ " and t.pack_qty>0   "
					+ " and m.prod_id="
					+ prod_id
					+ " and n.line_type in("
					+ line_type
					+ ")"
					+ " group by m.prod_no,m.prod_id,m.pi_no,m.pi_id, t.pack_qty ,"
					+ " t.price,n.erp_code,n.cust_spec,c.brand_name,c.CUST_ITEM_NAME,n.deliver_date, "
					+ " m.sale_ent_type	,m.currency_code "
					+ " order by deliver_date  )n where   rownum=1 ";
			Vector vcqty = this.getDataCentre().multiRowSelect(sql);
			if (vcqty.size() > 0) {
				this.putZIF_OMS_SALESORDER_CHANGE_VA02(vcqty, (String) ht
						.get("iv_vbeln"), 4, "", "", "", "", prod_id);
			}
		}

	}

	*//**
	 *收款分配单调整
	 * *//*
	public void upallo_m(int allo_m_id, int type, String comp_code,
			String doc_date) throws SinocpcException {
		String sql = "";

		Vector vcline = null;
		Hashtable hth = null;

		if (type == 1) {
			sql = " select a.other_no,a.funds_id,  "
					+ " to_char(sysdate, 'yyyymmdd') DOC_DATE,  "
					+ " a.funds_no,  " + " ''amt_deduct,  " + " ''fact_amt,  "
					+ " ''lc_interest,  " + " a.currency_code,  "
					+ " ''sap_account,2 erp_sap_stat,5 erp_stat,  "
					+ " to_char(sysdate,'yyyymmddhh24miss')fundsno, "
					+ " 'SA' doc_type,2 rongzitype   "
					+ " from fin_funds_allo_m_header a   "
					+ " where  allo_m_id =" + allo_m_id;
			hth = this.getDataCentre().oneRowSelect(sql);

			sql = "select a1.*, rownum seq\n"
					+ "  from (select c.sap_code sap_account,\n"
					+ "               '收款' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ "               - (n.allo_amt + n.modify_amt) amt,\n"
					+ "               '15' BSCHL,\n"
					+ "               '' ZZ02,\n" + "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,n.pi_no item_text\n"
					+ "          from fin_funds_allo_m_line   n,\n"
					+ "               fin_funds_allo_m_header m,\n"
					+ "               customer                c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and nvl(m.is_byhand, 0) <> 2\n"
					+ "           and m.allo_m_id = n.allo_m_id\n"
					+ "           and n.modify_amt <> 0\n"
					+ "           and (n.allo_amt + n.modify_amt)<>0 "
					+ "        union\n"
					+ "        select c.sap_code sap_account,\n"
					+ "               '收款' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ "               - (m.total_allo_amt + m.modify_amt) amt,\n"
					+ "               '15' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,m.pi_no item_text\n"
					+ "          from fin_funds_allo_m_header m, customer c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and nvl(m.is_byhand, 0) = 2\n"
					+ "           and m.modify_amt <> 0\n"
					+ "           and (m.total_allo_amt + m.modify_amt)<>0 "
					+ "\n"
					+ "        union\n"
					+ "        select c.sap_code sap_account,\n"
					+ "               '调整' || (select wm_concat(pi_no)\n"
					+ "                            from fin_funds_allo_m_line\n"
					+ "                           where allo_m_id ="
					+ allo_m_id
					+ "                             and modify_amt <> 0) alloc_nmbr,\n"
					+ "               2 linetype,\n"
					+ "               sum(n.allo_amt) amt,\n"
					+ "               '05' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               '调整' || (select wm_concat(pi_no)\n"
					+ "                            from fin_funds_allo_m_line\n"
					+ "                           where allo_m_id ="
					+ allo_m_id
					+ "                             and modify_amt <> 0) item_text\n"
					+ "          from fin_funds_allo_m_line   n,\n"
					+ "               fin_funds_allo_m_header m,\n"
					+ "               customer                c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.allo_m_id = n.allo_m_id\n"
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and n.modify_amt <> 0\n"
					+ "           and nvl(m.is_byhand, 0) <> 2\n"
					+ "         group by c.sap_code, m.currency_code\n"
					+ "        union\n"
					+ "        select c.sap_code sap_account,\n"
					+ "               '调整' || m.pi_no alloc_nmbr,\n"
					+ "               2 linetype,\n"
					+ "               sum(m.total_allo_amt) amt,\n"
					+ "               '05' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,'调整' || m.pi_no item_text\n"
					+ "          from fin_funds_allo_m_header m, customer c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and m.modify_amt <> 0\n"
					+ "           and nvl(m.is_byhand, 0) = 2\n"
					+ "         group by c.sap_code, m.currency_code, m.pi_no\n"
					+ "\n"
					+ "        union\n"
					+ "        select c.sap_code sap_account,\n"
					+ "               '暂收款' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ "               sum(n.modify_amt) amt,\n"
					+ "               '15' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,'暂收款' item_text\n"
					+ "          from fin_funds_allo_m_line   n,\n"
					+ "               fin_funds_allo_m_header m,\n"
					+ "               customer                c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.allo_m_id = n.allo_m_id\n"
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and n.modify_amt <> 0\n"
					+ "           and nvl(m.is_byhand, 0) <> 2\n"
					+ "         group by c.sap_code, m.currency_code\n"
					+ "        union\n"
					+ "        select c.sap_code sap_account,\n"
					+ "               '暂收款' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ "               sum(m.modify_amt) amt,\n"
					+ "               '15' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,'暂收款' item_text\n"
					+ "          from fin_funds_allo_m_header m, customer c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and m.modify_amt <> 0\n"
					+ "           and nvl(m.is_byhand, 0) = 2\n"
					+ "         group by c.sap_code, m.currency_code\n"
					+ "\n"
					+ "        ) a1";
			vcline = this.getDataCentre().multiRowSelect(sql);
		} else {
			sql = " select a.other_no,a.funds_id,  "
					+ " to_char(sysdate, 'yyyymmdd') DOC_DATE,  "
					+ " a.funds_no,  " + " ''amt_deduct,  " + " ''fact_amt,  "
					+ " ''lc_interest,  " + " a.currency_code,  "
					+ " ''sap_account,2 erp_sap_stat,5 erp_stat,  "
					+ " to_char(sysdate,'yyyymmddhh24miss')fundsno, "
					+ " 'SA'doc_type  "
					+ " from fin_funds_m_invoice_header a   "
					+ " where  allo_m_id =" + allo_m_id;
			hth = this.getDataCentre().oneRowSelect(sql);

			sql = "select a1.*, rownum seq\n"
					+ "  from (select c.sap_code sap_account,\n"
					+ "               '收款' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ "               - (n.invoice_check_amt + n.modify_amt) amt,\n"
					+ "               '15' BSCHL,\n"
					+ "               '' ZZ02,\n" + "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,b.pi_no item_text \n"
					+ "          from fin_funds_m_invoice_line   n,\n"
					+ "               fin_funds_invoice_line     b,\n"
					+ "               fin_funds_m_invoice_header m,\n"
					+ "               customer                   c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and m.allo_m_id = n.allo_m_id\n"
					+ "           and n.allo_id = b.allo_id\n"
					+ "           and b.fee_type = n.fee_type\n"
					+ "           and n.modify_amt <> 0\n"
					+ "           and (n.invoice_check_amt + n.modify_amt)<>0"
					+ "\n"
					+ "        union\n"
					+ "        select c.sap_code sap_account,\n"
					+ "               '调整' ||\n"
					+ "               (select wm_concat(pi_no)\n"
					+ "                  from fin_funds_invoice_line b, fin_funds_m_invoice_line n\n"
					+ "                 where n.allo_id = b.allo_id\n"
					+ "                   and b.fee_type = n.fee_type\n"
					+ "                   and allo_m_id ="
					+ allo_m_id
					+ "                   and modify_amt <> 0) alloc_nmbr,\n"
					+ "               2 linetype,\n"
					+ "               sum(n.invoice_check_amt) amt,\n"
					+ "               '05' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               '调整' ||\n"
					+ "               (select wm_concat(pi_no)\n"
					+ "                  from fin_funds_invoice_line b, fin_funds_m_invoice_line n\n"
					+ "                 where n.allo_id = b.allo_id\n"
					+ "                   and b.fee_type = n.fee_type\n"
					+ "                   and allo_m_id ="
					+ allo_m_id
					+ "                   and modify_amt <> 0) item_text\n"
					+ "          from fin_funds_m_invoice_line   n,\n"
					+ "               fin_funds_invoice_line     b,\n"
					+ "               fin_funds_m_invoice_header m,\n"
					+ "               customer                   c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.allo_m_id = n.allo_m_id\n"
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and n.allo_id = b.allo_id\n"
					+ "           and b.fee_type = n.fee_type\n"
					+ "           and n.modify_amt <> 0\n"
					+ "         group by c.sap_code, m.currency_code\n"
					+ "\n"
					+ "        union\n"
					+ "        select c.sap_code sap_account,\n"
					+ "               '暂收款' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ "               sum(n.modify_amt) amt,\n"
					+ "               '15' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,'暂收款' item_text \n"
					+ "          from fin_funds_m_invoice_line   n,\n"
					+ "               fin_funds_invoice_line     b,\n"
					+ "               fin_funds_m_invoice_header m,\n"
					+ "               customer                   c\n"
					+ "         where m.allo_m_id ="
					+ allo_m_id
					+ "           and m.allo_m_id = n.allo_m_id\n"
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and n.allo_id = b.allo_id\n"
					+ "           and b.fee_type = n.fee_type\n"
					+ "           and n.modify_amt <> 0\n"
					+ "         group by c.sap_code, m.currency_code\n"
					+ "\n"
					+ "        ) a1";

			vcline = this.getDataCentre().multiRowSelect(sql);

		}
		if (hth != null && vcline.size() > 0) {

			this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline, doc_date, Integer
					.parseInt((String) hth.get("funds_id")), 3, 2, 4,
					allo_m_id, type, comp_code, 1, "收款分配单调整");
		}

	}

	public void putZ_FI_RESET_CLEARED_ITEMS(int invoice_id, String i_stgrd)
			throws SinocpcException {

	}

	*//**
	 *到款红冲
	 * *//*
	public void putZRFC_CRM_F22_WRITE_OFF_01(int funds_id, String funds_m_no,
			String ivbudat) throws SinocpcException {
		String sql = "";

		sql = "select a.*,to_char(sysdate,'yyyy')iv_gjahr,to_char(sysdate,'yyyymmdd')iv_budat from fin_funds_sap a where  "
				+ " usable=2 and temp_type=1 and funds_id="
				+ funds_id
				+ " and fin_stat=1";
		Vector vc = this.getDataCentre().multiRowSelect(sql);

		if (vc.size() > 0) {
			for (int i = 0; i < vc.size(); i++) {
				Hashtable ht = (Hashtable) vc.elementAt(i);
				String iv_belnr = (String) ht.get("sap_no");
				int iv_gjahr = Integer.parseInt((String) ht.get("iv_gjahr"));
				String funds_no = (String) ht.get("funds_no");
				int sap_id = Integer.parseInt((String) ht.get("sap_id"));
				String comp_code = (String) ht.get("org_code");
				// String iv_budat=(String)ht.get("iv_budat");

				this.ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CXA(comp_code, iv_belnr,
						iv_gjahr, ivbudat, funds_id, funds_no, sap_id,
						funds_m_no, 1, "01", 2);

			}
		}

	}

	*//**
	 * 发票红冲
	 * *//*
	public void putZRFC_CRM_F22_WRITE_OFF_03(String sap_zuzhi, int funds_id,
			String sap_no, int yyyy, String yyyymmdd, String p_stgrd)
			throws SinocpcException {

		this.ZIF_OMS_ACC_DOCUMENT_CANCEL_F22CXA(sap_zuzhi, sap_no, yyyy,
				yyyymmdd, funds_id, "", 0, "", 2, "01", 4);
	}

	*//**
	 *发票手工行生成1000000000凭证 借 05 客户 贷 50 费用 贷 50 费用
	 * *//*
	public void putinvoice(int invoice_id, String ip_bldat)
			throws SinocpcException {

		String sql = "";
		String comp_code = "";
		int sale_ent_type = 0;
		// 判断费用发票类型 如果是赔款 则直接按组织生成凭证 如果不是按组织不同生成的凭证不一样

		sql = " select a.pi_no other_no,a.pi_no funds_no, "
				+ "  to_char(sysdate, 'yyyymmdd') DOC_DATE, '2' pzzs, "
				+ "  a.invoice_no,a.sale_ent_type, 		 "
				+ "  a.currency_code,case when a.sale_ent_type=1 then '1130' else '1500'end  comp_code, "
				+ "  to_char(sysdate,'yyyymmddhh24miss')fundsno, "
				+ "  'SA'doc_type,a.pi_no item_text,5 erp_sap_stat,2 erp_stat,2 rongzitype,b.order_cost_centre costcenter  "
				+ "  from bill_invoice_header a ,base_contract b   "
				+ "  where  a.org_id=b.org_id and a.invoice_id =" + invoice_id;
		Hashtable hth = this.getDataCentre().oneRowSelect(sql);

		sql = "select count(1)\n"
				+ "  from bill_invoice_header a, bill_invoice_line b\n"
				+ " where a.stat = 5\n"
				+ "   and a.invoice_id = b.invoice_id\n"
				+ "   and b.fee_type = 29\n" + "   and a.invoice_type = 2\n"
				+ "   and a.is_red <> 2\n" + "   and a.bill_type <> 2\n"
				+ "   and a.invoice_id =" + invoice_id;
		if (this.getDataCentre().intSelect(sql) > 0) {
			comp_code = (String) hth.get("comp_code");

			sql = "select a.*, rownum seq\n"
					+ "  from (select '赔款' ALLOC_NMBR,\n"
					+ "               1 linetype,\n"
					+ "               -other_AMT amt,\n"
					+ "               '40' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               v.subjects_no sap_account,m.pi_no item_text \n"
					+ "          from bill_invoice_header      m,\n"
					+ "               bill_invoice_line        n,\n"
					+ "               crm_sap_finance_subjects v,\n"
					+ "               customer                 c\n"

					+ "         where m.invoice_id = n.invoice_id\n"
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and n.fee_type = v.fee_type\n"
					+ "           and m.invoice_id ="
					+ invoice_id
					+ "           and m.stat = 5\n"
					+ "           and nvl(m.is_erp_process, 0) <> 2\n"
					+ "        union\n"
					+ "        select '赔款' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ "               sum(other_AMT) amt,\n"
					+ "               '15' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               c.sap_code sap_account,m.pi_no item_text\n"
					+ "          from bill_invoice_header      m,\n"
					+ "               bill_invoice_line        n,\n"
					+ "               crm_sap_finance_subjects v,\n"
					+ "               customer                 c\n"
					+ "         where m.invoice_id = n.invoice_id\n"
					+ "           and m.cust_id = c.cust_id\n"
					+ "           and n.fee_type = v.fee_type\n"
					+ "           and m.invoice_id ="
					+ invoice_id
					+ "           and m.stat = 5\n"
					+ "           and nvl(m.is_erp_process, 0) <> 2\n"
					+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
					+ "         order by a.linetype";
			Vector vcline = this.getDataCentre().multiRowSelect(sql);

			this.ZIF_OMS_ACC_DOCUMENT_POST_F_22_PK(hth, vcline, ip_bldat,
					invoice_id, 2, 2, 3, 0, 0, comp_code, 1, "赔款");

		} else {

			if (hth != null) {
				comp_code = (String) hth.get("comp_code");
				int sae_ent_type = Integer.parseInt((String) hth
						.get("sale_ent_type"));
				if (sae_ent_type == 1) {
					sql = "select a.*, rownum seq\n"
							+ "  from (select '费用类应收' ALLOC_NMBR,\n"
							+ "               1 linetype,\n"
							+ "               -other_AMT amt,\n"
							+ "               '50' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               v.subjects_no sap_account,m.pi_no item_text \n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"

							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "        union\n"
							+ "        select '费用类应收' ALLOC_NMBR,\n"
							+ "               2 linetype,\n"
							+ "               sum(other_AMT) amt,\n"
							+ "               '05' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               c.sap_code sap_account,m.pi_no item_text\n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
							+ "         order by a.linetype";
					Vector vcline = this.getDataCentre().multiRowSelect(sql);

					this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline, ip_bldat,
							invoice_id, 2, 2, 3, 0, 0, comp_code, 1, "费用发票");
				} else {
					sql = "select a.*, rownum seq\n"
							+ "  from (select '费用类应收' ALLOC_NMBR,\n"
							+ "               1 linetype,\n"
							+ "               -other_AMT amt,\n"
							+ "               '50' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               v.subjects_no sap_account,'代收费用款+'||c.sap_code||'+'||m.pi_no item_text \n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"

							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "        union\n"
							+ "        select '费用类应收' ALLOC_NMBR,\n"
							+ "               2 linetype,\n"
							+ "               sum(other_AMT) amt,\n"
							+ "               '05' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               '1500' sap_account,'代收费用款+'||c.sap_code||'+'||m.pi_no item_text\n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
							+ "         order by a.linetype";
					Vector vcline = this.getDataCentre().multiRowSelect(sql);

					this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline, ip_bldat,
							invoice_id, 2, 2, 3, 0, 0, "1130", 2, "费用发票");

					sql = "select a.*, rownum seq\n"
							+ "  from (select '费用类应收' ALLOC_NMBR,\n"
							+ "               3 linetype,\n"
							+ "               -other_AMT amt,\n"
							+ "               '35' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               '1130' sap_account,'代收费用款+'||c.sap_code||'+'||m.pi_no item_text \n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"

							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "        union\n"
							+ "        select '费用类应收' ALLOC_NMBR,\n"
							+ "               2 linetype,\n"
							+ "               sum(other_AMT) amt,\n"
							+ "               '05' BSCHL,\n"
							+ "               '' ZZ02,\n"
							+ "               '' ZZ01,\n"
							+ "               '' UMSKZ,\n"
							+ "               m.currency_code,\n"
							+ "               'SA' DOC_TYPE,\n"
							+ "               '1130' COMP_CODE,\n"
							+ "               c.sap_code sap_account,'代收费用款+'||c.sap_code||'+'||m.pi_no item_text\n"
							+ "          from bill_invoice_header      m,\n"
							+ "               bill_invoice_line        n,\n"
							+ "               crm_sap_finance_subjects v,\n"
							+ "               customer                 c\n"
							+ "         where m.invoice_id = n.invoice_id\n"
							+ "           and m.cust_id = c.cust_id\n"
							+ "           and n.fee_type = v.fee_type\n"
							+ "           and m.invoice_id ="
							+ invoice_id
							+ "           and m.stat = 5\n"
							+ "           and nvl(m.is_erp_process, 0) <> 2\n"
							+ "         group by m.pi_no, m.currency_code, c.sap_code) a\n"
							+ "         order by a.linetype";
					vcline = this.getDataCentre().multiRowSelect(sql);

					this.ZIF_OMS_ACC_DOCUMENT_POST_F_22(hth, vcline, ip_bldat,
							invoice_id, 2, 2, 3, 0, 0, "1500", 1, "费用发票");
				}
			}
		}

	}

	*//**
	 * 读1500组织物料的锁定成本 0509074R001 0800041R001A
	 * *//*
	public BigDecimal getZRFC_SCM_READ_ZCOPCCB11(String ip_matnr)
			throws SinocpcException {

		JCO.Function function = null;
		JCO.Table ztmtrack = null;
		BigDecimal price2800 = null;

		getConnection();
		function = createFunction(OMS_GET); // 取物料数据表
		if (function == null) {
			System.out.println(OMS_GET + "在sap中没有发现");
		} else {
			*//**
			 *输入要读取物料号码
			 * *//*
			JCO.ParameterList input = function.getImportParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
			input.setValue(ip_matnr, "IV_MATNR");

			JCO.ParameterList list = function.getTableParameterList();

			if (mConnection == null) {
				System.out.println("mConnection 为空");
			}
			mConnection.execute(function);

			ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。
			System.out.println("ztmtrack.getNumRows() = "
					+ ztmtrack.getNumRows());
			for (int i = 0; i < ztmtrack.getNumRows(); i++) {
				ztmtrack.setRow(i);// 指定行

				// System.out.println(
				// " 基本计量单位：" + ztmtrack.getString("MEINS")+"\n"
				// + " 评估范围："+ ztmtrack.getString("BWKEY")+"\n"
				// + " 物料号码："+ ztmtrack.getString("MATNR")+"\n"
				// + " 锁定价格："+ ztmtrack.getString("BWPRS")+"\n"
				// + " 价格单位："+ ztmtrack.getString("PEINH"));

				String bwkey = ztmtrack.getString("BWKEY");
				if (bwkey.equals("1100")) {

					price2800 = new BigDecimal(ztmtrack.getString("BWPRS"));
				}

			}
			if (mConnection != null) {
				mConnection.disconnect();
			}
		}
		return price2800;

	}

	*//**
	 * 读1500组织物料的锁定成本 0509074R001 0800041R001A
	 * *//*
	public String getZRFC_SCM_READ_ZCOPCCB112(String ip_matnr)
			throws SinocpcException {

		JCO.Function function = null;
		JCO.Table ztmtrack = null;
		String meins = "";

		getConnection();
		function = createFunction(OMS_GET); // 取物料数据表
		if (function == null) {
			System.out.println(OMS_GET + "在sap中没有发现");
		} else {
			*//**
			 *输入要读取物料号码
			 * *//*
			JCO.ParameterList input = function.getImportParameterList();// BT是按段，EQ是相等，CP是模糊三种匹配值
			input.setValue(ip_matnr, "IV_MATNR");

			JCO.ParameterList list = function.getTableParameterList();

			if (mConnection == null) {
				System.out.println("mConnection 为空");
			}
			mConnection.execute(function);

			ztmtrack = list.getTable("ET_OUTPUT"); // 是一个内表。
			System.out.println("ztmtrack.getNumRows() = "
					+ ztmtrack.getNumRows());
			for (int i = 0; i < ztmtrack.getNumRows(); i++) {
				ztmtrack.setRow(i);// 指定行

				// System.out.println(
				// " 基本计量单位：" + ztmtrack.getString("MEINS")+"\n"
				// + " 评估范围："+ ztmtrack.getString("BWKEY")+"\n"
				// + " 物料号码："+ ztmtrack.getString("MATNR")+"\n"
				// + " 锁定价格："+ ztmtrack.getString("BWPRS")+"\n"
				// + " 价格单位："+ ztmtrack.getString("PEINH"));

				String bwkey = ztmtrack.getString("BWKEY");
				if (bwkey.equals("1100")) {

					meins = ztmtrack.getString("MEINS");
				}

			}
			if (mConnection != null) {
				mConnection.disconnect();
			}
		}
		return meins;

	}

	*//**
	 * 取PDM BOM编制状态
	 * *//*
	public void pdmbomstat() throws SinocpcException {
		String sql = " select m.inspection_batchno,prod_no,m.pdm_bom_stat from sale_prod_header m "
				+ " where stat>1 and pdm_bom_date is null ";
		Vector vc = this.getDataCentre().multiRowSelect(sql);
		String order_code = "";
		int pdm_bom_stat = 1;
		String pdm_bom_date = "";
		if (vc.size() > 0) {
			for (int i = 0; i < vc.size(); i++) {
				Hashtable ht = (Hashtable) vc.elementAt(i);
				order_code = "'" + (String) ht.get("inspection_batchno")
						+ "','" + (String) ht.get("prod_no") + "'";

				sql = "  select a.stat,b.endtime from psc_order_weave a,cpcwf b where a.stat>1 "
						+ " and a.wfid=b.wfid  "
						+ " and a.src_weave_id = 0 "
						+ " and a.is_newdata = 2  "
						+ " and order_code in("
						+ order_code + ")";

				Hashtable hs = this.getPdmDataCentre().oneRowSelect(sql);
				if (hs != null) {
					pdm_bom_stat = Integer.parseInt((String) hs.get("stat"));
					pdm_bom_date = (String) hs.get("endtime");
					sql = "update sale_prod_header set pdm_bom_stat="
							+ pdm_bom_stat + ",pdm_bom_date='" + pdm_bom_date
							+ "'" + " where inspection_batchno in("
							+ order_code + ")" + " and prod_no in("
							+ order_code + ")";
					this.getDataCentre().update(sql);

				}
			}
		}
	}

	*//**
	 *同步PDM整机 内机 外机 产品名称
	 * *//*
	public void doZnwj(String item_code_zh) throws SinocpcException {

		String sql = "";
		if (item_code_zh.trim().length() > 0) {
			sql = " select item_h_code item_code from pro_item_header where item_h_code='"
					+ item_code_zh
					+ "'"
					+ " union "
					+ " select item_code from pro_item where item_h_id=( "
					+ " select item_h_id from pro_item_header where item_h_code='"
					+ item_code_zh + "'" + " ) ";
		} else {
			sql = " select item_h_code item_code from pro_item_header "
					+ " union " + " select item_code from pro_item ";
		}
		Vector vc = this.getDataCentre().multiRowSelect(sql);
		if (vc.size() > 0) {
			for (int i = 0; i < vc.size(); i++) {
				Hashtable ht = (Hashtable) vc.elementAt(i);

				sql = "select distinct itemdesc itemname from cpcitem where itemcode='"
						+ (String) ht.get("item_code") + "'" + " and rownum=1";
				Hashtable htcpc = this.getPdmDataCentre().oneRowSelect(sql);
				if (htcpc != null) {
					sql = "update pro_item set item_name='"
							+ (String) htcpc.get("itemname") + "'" + ",spec='"
							+ (String) htcpc.get("itemname") + "'"
							+ " where item_code='"
							+ (String) ht.get("item_code") + "'";
					this.getDataCentre().update(sql);

					sql = "update pro_item_header set item_h_name='"
							+ (String) htcpc.get("itemname") + "'"
							+ ",h_spec='" + (String) htcpc.get("itemname")
							+ "'" + " where item_h_code='"
							+ (String) ht.get("item_code") + "'";
					this.getDataCentre().update(sql);

				}

			}
		}

		// PDM选配系统标机禁用，更新OMS系统同时禁用
		sql = "update pro_item_header f\n"
				+ "   set f.usable = 1\n"
				+ " where item_h_id in\n"
				+ "       (select item_h_id\n"
				+ "          from pro_item\n"
				+ "         where item_code in (select psc_item_code\n"
				+ "                               from psc_item@pdm_aux_zs cs\n"
				+ "                              where cs.usable <> 2))";
		this.getDataCentre().update(sql);

	}

	*//**
	 * 短溢装写sap
	 * 
	 * @throws SinocpcException
	 *//*
	public void doCustoms(int customsid, BigDecimal amt)
			throws SinocpcException {
		String sql = "";
		String comp_code = "";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		String gl_date = sdf.format(new java.util.Date());

		sql = " select a.cpi_no other_no,a.cpi_no funds_no, "
				+ "  to_char(sysdate, 'yyyymmdd') DOC_DATE, '2' pzzs, "
				+ "  a.customs_no invoice_no,a.sale_ent_type, 		 "
				+ "  a.currency_code,case when a.sale_ent_type=1 then '1130' else '1500'end  comp_code, "
				+ "  to_char(sysdate,'yyyymmddhh24miss')fundsno, "
				+ "  'SA'doc_type,a.cpi_no item_text,5 erp_sap_stat,2 erp_stat,2 rongzitype,b.order_cost_centre costcenter  "
				+ "  from sale_customs_header a ,base_contract b   "
				+ "  where  a.org_id=b.org_id and a.customs_id =" + customsid;
		Hashtable hth = this.getDataCentre().oneRowSelect(sql);

		comp_code = (String) hth.get("comp_code");
		sql = "select sale_ent_type from sale_customs_header where customs_id="
				+ customsid;
		int saleenttype = this.getDataCentre().intSelect(sql);
		// 短装 报关比发货多
		// 05: 800373 Bg HK Company Limited
		// 50: 6051010006 其他业务收入-其他 金额-(金额/1.17)*0.17
		// 50： 2221020101 应交税费-应交增值税-销项税额 (金额/1.17)*0.17

		sql = "select round((" + amt + "/1.17)*0.17,2) from dual";
		BigDecimal zzsamt = Util.createBigDecimal(this.getDataCentre()
				.strSelect(sql));
		sql = "select custcode from BASE_Customs_CY where saporgid="
				+ comp_code;
		String sapcustcode = this.getDataCentre().strSelect(sql);

		if ((saleenttype == 1 || saleenttype == 2)
				&& (amt.compareTo(new BigDecimal("0")) > 0)) {

			sql = "select a.*, rownum seq\n"
					+ "  from (select '短装差异' ALLOC_NMBR,\n"
					+ "               1 linetype,-\n"
					+ amt.subtract(zzsamt)
					+ "                amt,\n"
					+ "               '50' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               '6051010006' sap_account,m.cpi_no item_text \n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "       union "
					+ "     select '短装差异' ALLOC_NMBR,\n"
					+ "               1 linetype,-\n"
					+ zzsamt
					+ "                amt,\n"
					+ "               '50' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               '2221020101' sap_account,m.cpi_no item_text \n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "        union\n"
					+ "        select '短装差异' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ amt
					+ "               amt,\n"
					+ "               '05' BSCHL,\n" // 记帐代码
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               '"
					+ sapcustcode
					+ "' sap_account,m.cpi_no item_text\n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "       ) a\n" + "         order by a.linetype";
		}
		// 溢装
		// 40：6001010001 主营业务收入-外销-成品
		// 15： 800373 Bg HK Company Limited
		else if ((saleenttype == 1 || saleenttype == 2)
				&& (amt.compareTo(new BigDecimal("0")) < 0)) {
			sql = "select a.*, rownum seq\n"
					+ "  from (select '短装差异' ALLOC_NMBR,\n"
					+ "               1 linetype,\n"
					+ amt
					+ "                amt,\n"
					+ "               '40' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               '6001010001' sap_account,m.cpi_no item_text \n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "        union\n"
					+ "        select '短装差异' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ amt
					+ "               amt,\n"
					+ "               '15' BSCHL,\n" // 记帐代码
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1130' COMP_CODE,\n"
					+ "               '"
					+ sapcustcode
					+ "' sap_account,m.cpi_no item_text\n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "       ) a\n" + "         order by a.linetype";
		}
		// 05：800373 Bg HK Company Limited
		// 50：6001010001 主营业务收入-外销-成品
		else if ((saleenttype == 3) && (amt.compareTo(new BigDecimal("0")) > 0)) {
			sql = "select a.*, rownum seq\n"
					+ "  from (select '短装差异' ALLOC_NMBR,\n"
					+ "               1 linetype,\n"
					+ amt
					+ "                amt,\n"
					+ "               '50' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1500' COMP_CODE,\n"
					+ "               '6001010001' sap_account,m.cpi_no item_text \n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "        union\n"
					+ "        select '短装差异' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ amt
					+ "               amt,\n"
					+ "               '05' BSCHL,\n" // 记帐代码
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1500' COMP_CODE,\n"
					+ "               '"
					+ sapcustcode
					+ "' sap_account,m.cpi_no item_text\n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "       ) a\n" + "         order by a.linetype";
		}
		// 40：6001010001 主营业务收入-外销-成品
		// 15： 800373 Bg HK Company Limited
		else if ((saleenttype == 3) && (amt.compareTo(new BigDecimal("0")) < 0)) {
			sql = "select a.*, rownum seq\n"
					+ "  from (select '短装差异' ALLOC_NMBR,\n"
					+ "               1 linetype,\n"
					+ amt
					+ "                amt,\n"
					+ "               '40' BSCHL,\n"
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1500' COMP_CODE,\n"
					+ "               '6001010001' sap_account,m.cpi_no item_text \n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "        union\n"
					+ "        select '短装差异' ALLOC_NMBR,\n"
					+ "               2 linetype,\n"
					+ amt
					+ "               amt,\n"
					+ "               '15' BSCHL,\n" // 记帐代码
					+ "               '' ZZ02,\n"
					+ "               '' ZZ01,\n"
					+ "               '' UMSKZ,\n"
					+ "               m.currency_code,\n"
					+ "               'SA' DOC_TYPE,\n"
					+ "               '1500' COMP_CODE,\n"
					+ "               '"
					+ sapcustcode
					+ "' sap_account,m.cpi_no item_text\n"
					+ "          from sale_customs_header      m\n"
					+ "         where  m.customs_id ="
					+ customsid
					+ "          and m.stat=5 and m.bill_type=1"
					+ "       ) a\n" + "         order by a.linetype";
		}

		Vector vcline = this.getDataCentre().multiRowSelect(sql);

		this.ZIF_OMS_ACC_DOCUMENT_POST_F_22_CY(hth, vcline, gl_date, customsid,
				comp_code, 1, "报关与发货差异", amt);

	}

*/}
